| Directory: | ./ |
|---|---|
| File: | sql/mysqld.cc |
| Date: | 2022-12-06 21:40:42 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 3245 | 3745 | 86.6% |
| Branches: | 3363 | 7536 | 44.6% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* Copyright (c) 2000, 2022, Oracle and/or its affiliates. | ||
| 2 | |||
| 3 | This program is free software; you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License, version 2.0, | ||
| 5 | as published by the Free Software Foundation. | ||
| 6 | |||
| 7 | This program is also distributed with certain software (including | ||
| 8 | but not limited to OpenSSL) that is licensed under separate terms, | ||
| 9 | as designated in a particular file or component or in included license | ||
| 10 | documentation. The authors of MySQL hereby grant you an additional | ||
| 11 | permission to link the program and your derivative works with the | ||
| 12 | separately licensed software that they have included with MySQL. | ||
| 13 | |||
| 14 | This program is distributed in the hope that it will be useful, | ||
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 | GNU General Public License, version 2.0, for more details. | ||
| 18 | |||
| 19 | You should have received a copy of the GNU General Public License | ||
| 20 | along with this program; if not, write to the Free Software | ||
| 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ | ||
| 22 | |||
| 23 | /** | ||
| 24 | @file sql/mysqld.cc | ||
| 25 | MySQL server daemon. | ||
| 26 | */ | ||
| 27 | |||
| 28 | /* clang-format off */ | ||
| 29 | /** | ||
| 30 | @mainpage Welcome | ||
| 31 | |||
| 32 | Welcome to the MySQL source code documentation. | ||
| 33 | |||
| 34 | This documentation covers primarily the MySQL server, | ||
| 35 | for the @c mysqld process. | ||
| 36 | |||
| 37 | Other programs, like the MySQL Router, are also documented, | ||
| 38 | see the @ref PAGE_SERVER_TOOLS section. | ||
| 39 | |||
| 40 | The order chosen to present the content is to start with low level components, | ||
| 41 | and build upon previous sections, so that code is presented in a logical order. | ||
| 42 | |||
| 43 | For some sections, a full article (Doxygen 'page') presents the component in detail. | ||
| 44 | |||
| 45 | For other sections, only links are provided, as a starting point into the component. | ||
| 46 | |||
| 47 | For the user manual, see http://dev.mysql.com/doc/refman/8.0/en/ | ||
| 48 | |||
| 49 | For the internals manual, see https://dev.mysql.com/doc/internals/en/index.html | ||
| 50 | |||
| 51 | This documentation is published for each release, starting with MySQL 8.0. | ||
| 52 | |||
| 53 | The present document corresponds to: | ||
| 54 | |||
| 55 | Document generated on: ${DOXYGEN_GENERATION_DATE}, | ||
| 56 | branch: ${DOXYGEN_GENERATION_BRANCH}, | ||
| 57 | revision: ${DOXYGEN_GENERATION_REVISION} | ||
| 58 | |||
| 59 | For the latest available version, see https://dev.mysql.com/doc/dev/mysql-server/latest/ | ||
| 60 | |||
| 61 | For other versions, see https://dev.mysql.com/doc/index-archive.html | ||
| 62 | */ | ||
| 63 | |||
| 64 | /** | ||
| 65 | @page PAGE_GET_STARTED Getting Started | ||
| 66 | |||
| 67 | - @ref start_source | ||
| 68 | - @subpage PAGE_CODING_GUIDELINES | ||
| 69 | - @ref start_debug | ||
| 70 | |||
| 71 | @section start_source Build from source | ||
| 72 | |||
| 73 | See https://dev.mysql.com/doc/refman/8.0/en/source-installation.html | ||
| 74 | |||
| 75 | @section start_debug Debugging | ||
| 76 | |||
| 77 | The easiest way to install a server, and attach a debugger to it, | ||
| 78 | is to start the mysql-test-run (MTR) tool with debugging options | ||
| 79 | |||
| 80 | @verbatim | ||
| 81 | cd mysql-test | ||
| 82 | ./mtr --ddd main.parser | ||
| 83 | @endverbatim | ||
| 84 | |||
| 85 | The following functions are good candidates for breakpoints: | ||
| 86 | - #my_message_sql | ||
| 87 | - #dispatch_command | ||
| 88 | |||
| 89 | Replace 'main.parser' with another test script, or write your own, to debug a specific area. | ||
| 90 | */ | ||
| 91 | |||
| 92 | /** | ||
| 93 | @page PAGE_CODING_GUIDELINES Coding Guidelines | ||
| 94 | |||
| 95 | This section shows the guidelines that MySQL developers | ||
| 96 | follow when writing new code. | ||
| 97 | |||
| 98 | New MySQL code uses the Google C++ coding style | ||
| 99 | (https://google.github.io/styleguide/cppguide.html), with two | ||
| 100 | exceptions: | ||
| 101 | |||
| 102 | - Member variable names: Do not use foo_. Instead, use | ||
| 103 | m_foo (non-static) or s_foo (static). | ||
| 104 | |||
| 105 | - Do not use non-const references as function parameters, even if they | ||
| 106 | are optional. Instead, use pointers for in/out and output parameters. | ||
| 107 | (This matches an older version of the Google style guide.) Do not use | ||
| 108 | references, whether const or non-const, as struct or class members. | ||
| 109 | |||
| 110 | Old projects and modifications to old code use an older MySQL-specific | ||
| 111 | style for the time being. Since 8.0, MySQL style uses the same formatting | ||
| 112 | rules as Google coding style (e.g., brace placement, indentation, line | ||
| 113 | lengths, etc.), but differs in a few important aspects: | ||
| 114 | |||
| 115 | - Class names: Do not use MyClass. Instead, use My_class. | ||
| 116 | |||
| 117 | - Function names: Use snake_case(). | ||
| 118 | |||
| 119 | - Comment Style: Use either the // or <em>/</em>* *<em>/</em> syntax. // is | ||
| 120 | much more common but both syntaxes are permitted for the time being. | ||
| 121 | |||
| 122 | - Doxygen comments: Use <em>/</em>** ... *<em>/</em> syntax and not ///. | ||
| 123 | |||
| 124 | - Doxygen commands: Use '@' and not '\' for doxygen commands. | ||
| 125 | |||
| 126 | - You may see structs starting with st_ and being typedef-ed to some | ||
| 127 | UPPERCASE (e.g. typedef struct st_foo { ... } FOO). However, | ||
| 128 | this is legacy from when the codebase contained C. Do not make such new | ||
| 129 | typedefs nor structs with st_ prefixes, and feel free to remove those that | ||
| 130 | already exist, except in public header files that are part of libmysql | ||
| 131 | (which need to be parseable as C99). | ||
| 132 | |||
| 133 | |||
| 134 | Code formatting is enforced by use of clang-format throughout the code | ||
| 135 | base. However, note that formatting is only one part of coding style; | ||
| 136 | you are required to take care of non-formatting issues yourself, such as | ||
| 137 | following naming conventions, having clear ownership of code or minimizing | ||
| 138 | the use of macros. See the Google coding style guide for the entire list. | ||
| 139 | |||
| 140 | Consistent style is important for us, because everyone must know what to | ||
| 141 | expect. Knowing our rules, you'll find it easier to read our code, and when | ||
| 142 | you decide to contribute (which we hope you'll consider!) we'll find it | ||
| 143 | easier to read and review your code. | ||
| 144 | |||
| 145 | - @subpage GENERAL_DEVELOPMENT_GUIDELINES | ||
| 146 | - @subpage CPP_CODING_GUIDELINES_FOR_NDB_SE | ||
| 147 | - @subpage DBUG_TAGS | ||
| 148 | |||
| 149 | */ | ||
| 150 | |||
| 151 | /** | ||
| 152 | @page PAGE_INFRASTRUCTURE Infrastructure | ||
| 153 | |||
| 154 | @section infra_basic Basic classes and templates | ||
| 155 | |||
| 156 | @subsection infra_basic_container Container | ||
| 157 | |||
| 158 | See #DYNAMIC_ARRAY, #List, #I_P_List, #LF_HASH. | ||
| 159 | |||
| 160 | @subsection infra_basic_syncho Synchronization | ||
| 161 | |||
| 162 | See #native_mutex_t, #native_rw_lock_t, #native_cond_t. | ||
| 163 | |||
| 164 | @subsection infra_basic_fileio File IO | ||
| 165 | |||
| 166 | See #my_open, #my_dir. | ||
| 167 | |||
| 168 | @section infra_server_blocks Server building blocks | ||
| 169 | |||
| 170 | @subsection infra_server_blocks_vio Virtual Input Output | ||
| 171 | |||
| 172 | See #Vio, #vio_init. | ||
| 173 | |||
| 174 | @section deployment Deployment | ||
| 175 | |||
| 176 | @subsection deploy_install Installation | ||
| 177 | |||
| 178 | See #opt_initialize, #bootstrap::run_bootstrap_thread. | ||
| 179 | |||
| 180 | @subsection deploy_startup Startup | ||
| 181 | |||
| 182 | See #mysqld_main. | ||
| 183 | |||
| 184 | @subsection deploy_shutdown Shutdown | ||
| 185 | |||
| 186 | See #handle_fatal_signal, #signal_hand. | ||
| 187 | |||
| 188 | @subsection deploy_upgrade Upgrade | ||
| 189 | |||
| 190 | See #Mysql::Tools::Upgrade::Program. | ||
| 191 | |||
| 192 | */ | ||
| 193 | |||
| 194 | /** | ||
| 195 | @page PAGE_PROTOCOL Client/Server Protocol | ||
| 196 | |||
| 197 | @section protocol_overview Overview | ||
| 198 | |||
| 199 | The MySQL protocol is used between MySQL Clients and a MySQL Server. | ||
| 200 | It is implemented by: | ||
| 201 | - Connectors (Connector/C, Connector/J, and so forth) | ||
| 202 | - MySQL Proxy | ||
| 203 | - Communication between master and slave replication servers | ||
| 204 | |||
| 205 | The protocol supports these features: | ||
| 206 | - Transparent encryption using SSL | ||
| 207 | - Transparent compression | ||
| 208 | - A @ref page_protocol_connection_phase where capabilities and | ||
| 209 | authentication data are exchanged | ||
| 210 | - A @ref page_protocol_command_phase which accepts commands | ||
| 211 | from the client and executes them | ||
| 212 | |||
| 213 | Further reading: | ||
| 214 | - @subpage page_protocol_basics | ||
| 215 | - @subpage page_protocol_connection_lifecycle | ||
| 216 | */ | ||
| 217 | |||
| 218 | /** @page page_mysqlx_protocol X %Protocol | ||
| 219 | |||
| 220 | @par Topics in this section: | ||
| 221 | |||
| 222 | - @subpage mysqlx_protocol_lifecycle | ||
| 223 | - @subpage mysqlx_protocol_authentication | ||
| 224 | - @subpage mysqlx_protocol_messages | ||
| 225 | - @subpage mysqlx_protocol_expectations | ||
| 226 | - @subpage mysqlx_protocol_notices | ||
| 227 | - @subpage mysqlx_protocol_xplugin | ||
| 228 | - @subpage mysqlx_protocol_use_cases | ||
| 229 | - @subpage mysqlx_protocol_implementation | ||
| 230 | - @subpage mysqlx_protocol_comparison | ||
| 231 | - @subpage mysqlx_community_connector | ||
| 232 | |||
| 233 | The X %Protocol is implemented by the X Plugin and the following | ||
| 234 | MySQL clients support the protocol: | ||
| 235 | |||
| 236 | - MYSQLXSHELL | ||
| 237 | |||
| 238 | - MySQL for Visual Studio 2.0.2 or higher | ||
| 239 | |||
| 240 | - MySQL Connector/J 6.0.2 or higher | ||
| 241 | |||
| 242 | - MySQL Connector/Net 7.0.2 or higher | ||
| 243 | |||
| 244 | - MySQL Connector/Node.js | ||
| 245 | */ | ||
| 246 | |||
| 247 | |||
| 248 | /** | ||
| 249 | @page PAGE_SQL_EXECUTION SQL Query Execution | ||
| 250 | |||
| 251 | @section sql_query_exec_parsing SQL Parsing | ||
| 252 | |||
| 253 | The parser processes SQL strings and builds a tree representation of them. | ||
| 254 | |||
| 255 | See @ref GROUP_PARSER. | ||
| 256 | |||
| 257 | @subpage PAGE_SQL_Optimizer | ||
| 258 | |||
| 259 | @subpage stored_programs | ||
| 260 | |||
| 261 | @section sql_query_exec_prepared Prepared statements | ||
| 262 | |||
| 263 | See #mysql_stmt_prepare | ||
| 264 | |||
| 265 | @section func_stored_proc Stored procedures | ||
| 266 | |||
| 267 | See #sp_head, #sp_instr. | ||
| 268 | |||
| 269 | @section sql_query_exec_sql_functions SQL Functions | ||
| 270 | |||
| 271 | See #Item_func | ||
| 272 | |||
| 273 | @section sql_query_exec_error_handling Error handling | ||
| 274 | |||
| 275 | See #my_message, #my_error | ||
| 276 | |||
| 277 | @subpage PAGE_TXN | ||
| 278 | |||
| 279 | */ | ||
| 280 | |||
| 281 | /** | ||
| 282 | @page PAGE_STORAGE Data Storage | ||
| 283 | |||
| 284 | @section storage_innodb Innodb | ||
| 285 | |||
| 286 | See #ha_innobase or read details about InnoDB internals: | ||
| 287 | - @subpage PAGE_INNODB_PFS | ||
| 288 | - @subpage PAGE_INNODB_REDO_LOG | ||
| 289 | - @subpage PAGE_INNODB_LOCK_SYS | ||
| 290 | - @subpage PAGE_INNODB_UTILS | ||
| 291 | |||
| 292 | @section storage_temptable Temp table | ||
| 293 | |||
| 294 | Before 8.0, temporary tables were handled by heap engine. | ||
| 295 | The heap engine had no feature to store bigger tables on disk. | ||
| 296 | |||
| 297 | Since 8.0, there is a brand new temptable engine, which | ||
| 298 | is written from scratch using c++11. It has following advantages: | ||
| 299 | - it is able to store bigger tables on disk (in temporary files), | ||
| 300 | - it uses row format with variable size (can save memory for varchars), | ||
| 301 | - it is better designed (easier to maintain). | ||
| 302 | |||
| 303 | @subpage PAGE_TEMPTABLE | ||
| 304 | |||
| 305 | */ | ||
| 306 | |||
| 307 | |||
| 308 | /** | ||
| 309 | @page PAGE_REPLICATION Replication | ||
| 310 | |||
| 311 | @subpage PAGE_RPL_FIELD_METADATA | ||
| 312 | |||
| 313 | */ | ||
| 314 | |||
| 315 | /** | ||
| 316 | @page PAGE_TXN Transactions | ||
| 317 | |||
| 318 | See #trans_begin, #trans_commit, #trans_rollback. | ||
| 319 | */ | ||
| 320 | |||
| 321 | /** | ||
| 322 | @page PAGE_SECURITY Security | ||
| 323 | |||
| 324 | @subpage AUTHORIZATION_PAGE | ||
| 325 | @subpage PAGE_KEYRING_COMPONENT | ||
| 326 | */ | ||
| 327 | |||
| 328 | |||
| 329 | /** | ||
| 330 | @page PAGE_MONITORING Monitoring | ||
| 331 | |||
| 332 | @subpage PAGE_PFS | ||
| 333 | */ | ||
| 334 | |||
| 335 | /** | ||
| 336 | @page PAGE_EXTENDING Extending MySQL | ||
| 337 | |||
| 338 | Components | ||
| 339 | ---------- | ||
| 340 | |||
| 341 | MySQL 8.0 introduces support for extending the server through components. | ||
| 342 | Components can communicate with other components through service APIs. | ||
| 343 | And can provide implementations of service APIs for other components to use. | ||
| 344 | All components are equal and can communicate with all other components. | ||
| 345 | Service implementations can be found by name via a registry service handle | ||
| 346 | which is passed to the component initialization function. | ||
| 347 | There can be multiple service API implementations for a single service API. | ||
| 348 | One of them is the default implementation. | ||
| 349 | Service API are stateless by definition. If they need to handle state or | ||
| 350 | object instances they need to do so by using factory methods and instance | ||
| 351 | handles. | ||
| 352 | |||
| 353 | To ease up transition to the component model the current server | ||
| 354 | functionality (server proper and plugins) is contained within | ||
| 355 | a dedicated built in server component. The server component currently | ||
| 356 | contains all of the functionality provided by the server and | ||
| 357 | classical server plugins. | ||
| 358 | |||
| 359 | More components can be installed via the "INSTALL COMPONENT" SQL command. | ||
| 360 | |||
| 361 | The component infrastructure is designed as a replacement for the classical | ||
| 362 | MySQL plugin system as it does not suffer from some of the limitations of it | ||
| 363 | and provides better isolation for the component code. | ||
| 364 | |||
| 365 | See @subpage PAGE_COMPONENTS. | ||
| 366 | |||
| 367 | Plugins and Services | ||
| 368 | -------------------- | ||
| 369 | |||
| 370 | As of MySQL 5.1 the server functionality can be extended through | ||
| 371 | installing (dynamically or statically linked) extra code modules | ||
| 372 | called plugins. | ||
| 373 | |||
| 374 | The server defines a set of well known plugin APIs that the modules | ||
| 375 | can implement. | ||
| 376 | |||
| 377 | To allow plugins to reuse server code the server exposes a pre-defined | ||
| 378 | set of functions to plugins called plugin services. | ||
| 379 | |||
| 380 | See the following for more details: | ||
| 381 | - @subpage page_ext_plugins | ||
| 382 | - @subpage page_ext_plugin_services | ||
| 383 | |||
| 384 | |||
| 385 | User Defined Functions | ||
| 386 | ---------------------- | ||
| 387 | |||
| 388 | Native code user defined functions can be added to MySQL server using | ||
| 389 | the CREATE FUNCTION ... SONAME syntax. | ||
| 390 | |||
| 391 | These can co-exit with @ref page_ext_plugins or reside in their own | ||
| 392 | separate binaries. | ||
| 393 | |||
| 394 | To learn how to create these user defined functions see @subpage page_ext_udf | ||
| 395 | */ | ||
| 396 | |||
| 397 | |||
| 398 | /** | ||
| 399 | @page PAGE_SERVICES Available services | ||
| 400 | |||
| 401 | @subpage PAGE_TABLE_ACCESS_SERVICE | ||
| 402 | */ | ||
| 403 | |||
| 404 | |||
| 405 | /** | ||
| 406 | @page PAGE_SERVER_TOOLS Server tools | ||
| 407 | |||
| 408 | - @subpage PAGE_MYSQL_ROUTER | ||
| 409 | */ | ||
| 410 | |||
| 411 | |||
| 412 | /** | ||
| 413 | @page PAGE_CLIENT_TOOLS Client tools | ||
| 414 | |||
| 415 | See mysqldump.cc mysql.cc | ||
| 416 | */ | ||
| 417 | |||
| 418 | |||
| 419 | /** | ||
| 420 | @page PAGE_TESTING_TOOLS Testing Tools | ||
| 421 | |||
| 422 | - @subpage PAGE_MYSQL_TEST_RUN | ||
| 423 | */ | ||
| 424 | |||
| 425 | /** | ||
| 426 | @page PAGE_DEV_TOOLS Development Tools | ||
| 427 | |||
| 428 | - @subpage PAGE_LOCK_ORDER | ||
| 429 | */ | ||
| 430 | |||
| 431 | /** | ||
| 432 | @page PAGE_CODE_PATHS Code paths | ||
| 433 | |||
| 434 | This section details how the server executes some statements, | ||
| 435 | to illustrate how different parts work together. | ||
| 436 | |||
| 437 | Note that this overall view might take some shortcuts, | ||
| 438 | hiding some details or taking liberties with the notations, | ||
| 439 | to present the whole code structure in a comprehensible way. | ||
| 440 | |||
| 441 | - @subpage CODE_PATH_CREATE_TABLE | ||
| 442 | */ | ||
| 443 | |||
| 444 | /** | ||
| 445 | @page CODE_PATH_CREATE_TABLE CREATE TABLE | ||
| 446 | |||
| 447 | @section CREATE_TABLE_PARSER Parser | ||
| 448 | |||
| 449 | @startuml | ||
| 450 | |||
| 451 | actor ddl as "CREATE TABLE Query" | ||
| 452 | participant server as "MySQL Server" | ||
| 453 | participant parser as "SQL Parser" | ||
| 454 | participant bison as "Bison Parser" | ||
| 455 | participant lexer as "Lexical Scanner" | ||
| 456 | participant pt as "Parse Tree Nodes" | ||
| 457 | |||
| 458 | ddl -> server : DDL QUERY TEXT | ||
| 459 | server -> parser : THD::sql_parser() | ||
| 460 | == Bison parser == | ||
| 461 | parser -> bison : MYSQLparse() | ||
| 462 | bison -> lexer : MYSQLlex() | ||
| 463 | bison <-- lexer : yylval, yylloc | ||
| 464 | bison -> pt : new | ||
| 465 | activate pt | ||
| 466 | parser <-- pt : Abstract Syntax Tree | ||
| 467 | |||
| 468 | @enduml | ||
| 469 | |||
| 470 | When a query is sent to the server, | ||
| 471 | the first step is to invoke the bison parser | ||
| 472 | to build an Abstract Syntax Tree to represent the query text. | ||
| 473 | |||
| 474 | Assume the following statement: | ||
| 475 | @verbatim | ||
| 476 | CREATE TABLE test.t1 (a int) ENGINE = "INNODB"; | ||
| 477 | @endverbatim | ||
| 478 | |||
| 479 | In the bison grammar file, the rule implementing the CREATE TABLE | ||
| 480 | statement is @c create_table_stmt. | ||
| 481 | |||
| 482 | The tree created is an object of class @ref PT_create_table_stmt. | ||
| 483 | |||
| 484 | This parse tree node has several related nodes, such as: | ||
| 485 | - @ref PT_create_table_option and sub classes, for table options. | ||
| 486 | - @ref PT_table_element and sub classes, for the columns, indexes, etc. | ||
| 487 | |||
| 488 | The collection of nodes returned after the bison parsing is known | ||
| 489 | as the "Abstract Syntax Tree" that represents a SQL query. | ||
| 490 | |||
| 491 | @section CREATE_TABLE_CMD Sql command | ||
| 492 | |||
| 493 | @startuml | ||
| 494 | |||
| 495 | actor ddl as "CREATE TABLE Query" | ||
| 496 | participant server as "MySQL Server" | ||
| 497 | participant parser as "SQL Parser" | ||
| 498 | participant ast as "Abstract Syntax Tree" | ||
| 499 | participant cmd as "SQL Command" | ||
| 500 | participant ci as "HA_CREATE_INFO" | ||
| 501 | participant plugin as "MySQL plugin" | ||
| 502 | |||
| 503 | ddl -> server : DDL QUERY TEXT | ||
| 504 | server -> parser : THD::sql_parser() | ||
| 505 | == Bison parser == | ||
| 506 | == Build SQL command == | ||
| 507 | parser -> ast : make_cmd() | ||
| 508 | ast -> ast : contextualize() | ||
| 509 | ast -> ci : build() | ||
| 510 | activate ci | ||
| 511 | ci -> plugin : ha_resolve_engine() | ||
| 512 | ci <-- plugin : storage engine handlerton | ||
| 513 | ast <-- ci : Parse Tree (contextualized) | ||
| 514 | ast -> cmd : build() | ||
| 515 | activate cmd | ||
| 516 | server <-- cmd : SQL Command | ||
| 517 | |||
| 518 | @enduml | ||
| 519 | |||
| 520 | Once the bison parser has finished parsing a query text, | ||
| 521 | the next step is to build a SQL command from the Abstract Syntax Tree. | ||
| 522 | |||
| 523 | In the Abstract Syntax Tree, attributes like a storage engine name | ||
| 524 | ("INNODB") are represented as strings, taken from the query text. | ||
| 525 | |||
| 526 | These attributes need to be converted to objects in the SQL context, | ||
| 527 | such as an @ref innodb_hton pointer to represent the INNODB storage engine. | ||
| 528 | |||
| 529 | The process that performs these transformations is contextualize(). | ||
| 530 | |||
| 531 | The @ref Parse_tree_root class is an abstract factory, building @ref Sql_cmd | ||
| 532 | objects. | ||
| 533 | |||
| 534 | For a CREATE TABLE statement, class @ref PT_create_table_stmt builds a | ||
| 535 | concrete @ref Sql_cmd_create_table object. | ||
| 536 | |||
| 537 | @ref PT_create_table_stmt::make_cmd() in particular performs the following | ||
| 538 | actions: | ||
| 539 | - contextualize the parse tree for the CREATE TABLE statement. | ||
| 540 | - build a @ref HA_CREATE_INFO structure to represent the table DDL. | ||
| 541 | - resolve the storage engine name to an actual @ref handlerton pointer, | ||
| 542 | in @ref PT_create_table_engine_option::contextualize() | ||
| 543 | |||
| 544 | @section CREATE_TABLE_RUNTIME Runtime execution | ||
| 545 | |||
| 546 | @startuml | ||
| 547 | |||
| 548 | actor ddl as "CREATE TABLE Query" | ||
| 549 | participant server as "MySQL Server" | ||
| 550 | participant cmd as "SQL Command" | ||
| 551 | participant rt as "Runtime" | ||
| 552 | |||
| 553 | ddl -> server : DDL QUERY TEXT | ||
| 554 | == Bison parser == | ||
| 555 | == Build SQL command == | ||
| 556 | == Execute SQL command == | ||
| 557 | server -> cmd : execute() | ||
| 558 | cmd -> rt : mysql_create_table() | ||
| 559 | |||
| 560 | @enduml | ||
| 561 | |||
| 562 | Execution of a CREATE TABLE statement invokes | ||
| 563 | @ref Sql_cmd_create_table::execute(), | ||
| 564 | which in turns calls: | ||
| 565 | - @ref mysql_create_table(), | ||
| 566 | - @ref mysql_create_table_no_lock(), | ||
| 567 | - @ref create_table_impl(), | ||
| 568 | - @ref rea_create_base_table(). | ||
| 569 | |||
| 570 | Execution of this code is the runtime implementation of the CREATE TABLE | ||
| 571 | statement, and eventually leads to: | ||
| 572 | - @ref dd::create_table(), to create the table in the Data Dictionary, | ||
| 573 | - @ref ha_create_table(), to create the table in the handlerton. | ||
| 574 | |||
| 575 | Details about the dictionary and the storage engine are expanded | ||
| 576 | in the following two sections. | ||
| 577 | |||
| 578 | |||
| 579 | @section CREATE_TABLE_DD Data Dictionary | ||
| 580 | |||
| 581 | @startuml | ||
| 582 | |||
| 583 | actor ddl as "CREATE TABLE Query" | ||
| 584 | participant server as "MySQL Server" | ||
| 585 | participant rt as "Runtime" | ||
| 586 | participant dd as "Data Dictionary" | ||
| 587 | participant ddt as "Data Dictionary Table" | ||
| 588 | participant sdi as "Serialized Dictionary Information" | ||
| 589 | participant hton as "Handlerton" | ||
| 590 | participant se as "Storage Engine" | ||
| 591 | participant ts as "Tablespace" | ||
| 592 | |||
| 593 | ddl -> server : DDL QUERY TEXT | ||
| 594 | == ... == | ||
| 595 | server -> rt : ( execution code path ) | ||
| 596 | == Data Dictionary == | ||
| 597 | rt -> dd : dd::create_table() | ||
| 598 | dd -> ddt : build dd::Table() | ||
| 599 | activate ddt | ||
| 600 | rt <-- ddt : dd:Table instance | ||
| 601 | == Serialized Dictionary Information == | ||
| 602 | rt -> dd : store() | ||
| 603 | dd -> sdi : dd::sdi::store() | ||
| 604 | sdi -> sdi : sdi_tablespace::store_tbl_sdi() | ||
| 605 | == Storage Engine (Tablespace) == | ||
| 606 | sdi -> hton : handlerton::sdi() | ||
| 607 | hton -> se : ::sdi() implementation. | ||
| 608 | se -> ts : write metadata in tablespace | ||
| 609 | |||
| 610 | @enduml | ||
| 611 | |||
| 612 | In the data dictionary, creation of a new table calls: | ||
| 613 | - @ref dd::create_dd_user_table() | ||
| 614 | - @ref fill_dd_table_from_create_info() | ||
| 615 | |||
| 616 | The data dictionary code parses the content of the HA_CREATE_INFO | ||
| 617 | input, and builds a @ref dd::Table object, to represent the table metadata. | ||
| 618 | Part of this metadata includes the storage engine name. | ||
| 619 | |||
| 620 | The runtime code then calls @c store() to save this new metadata. | ||
| 621 | |||
| 622 | To store a table metadata, the data dictionary code first serialize it | ||
| 623 | into an sdi format. | ||
| 624 | |||
| 625 | The serialized object is then stored in persistence, | ||
| 626 | either in a tablespace or in a file: | ||
| 627 | - @ref sdi_tablespace::store_tbl_sdi() | ||
| 628 | - @ref sfi_file::store_tbl_sdi() | ||
| 629 | |||
| 630 | When storing data into a tablespace, the storage engine handlerton is | ||
| 631 | invoked, so that the storage engine can ultimately store | ||
| 632 | the table metadata in the tablespace maintained by the storage engine. | ||
| 633 | |||
| 634 | @section CREATE_TABLE_SE Storage Engine | ||
| 635 | |||
| 636 | @startuml | ||
| 637 | |||
| 638 | actor ddl as "CREATE TABLE Query" | ||
| 639 | participant server as "MySQL Server" | ||
| 640 | participant rt as "Runtime" | ||
| 641 | participant sei as "Storage Engine Interface" | ||
| 642 | participant hton as "Storage Engine Handlerton" | ||
| 643 | participant handler as "Storage Engine Handler" | ||
| 644 | |||
| 645 | ddl -> server : DDL QUERY TEXT | ||
| 646 | == ... == | ||
| 647 | server -> rt : ( execution code path ) | ||
| 648 | == Storage Engine (table) == | ||
| 649 | rt -> sei : ha_create_table() | ||
| 650 | sei -> hton : handlerton::create() | ||
| 651 | hton -> handler : (build a new table handler) | ||
| 652 | activate handler | ||
| 653 | sei <-- handler : storage engine table handler | ||
| 654 | sei -> handler : handler::create() | ||
| 655 | |||
| 656 | @enduml | ||
| 657 | |||
| 658 | When execution of the CREATE TABLE statement | ||
| 659 | reaches the storage engine interface, | ||
| 660 | the SQL layer function @ref ha_create_table() | ||
| 661 | invokes the storage engine @ref handlerton::create() | ||
| 662 | method to instantiate a new storage engine table, | ||
| 663 | represented by @ref handler. | ||
| 664 | The SQL layer then calls @ref handler::create() to create | ||
| 665 | the table inside the storage engine. | ||
| 666 | */ | ||
| 667 | |||
| 668 | /** | ||
| 669 | @page PAGE_SQL_Optimizer SQL Optimizer | ||
| 670 | |||
| 671 | The task of query optimizer is to determine the most efficient means for | ||
| 672 | executing queries. The query optimizer consists of the following | ||
| 673 | sub-modules: | ||
| 674 | |||
| 675 | - @ref Query_Resolver | ||
| 676 | - @ref Query_Optimizer | ||
| 677 | - @ref Query_Planner | ||
| 678 | - @ref Query_Executor | ||
| 679 | |||
| 680 | @subpage PAGE_OPT_TRACE | ||
| 681 | |||
| 682 | Additional articles about the query optimizer: | ||
| 683 | |||
| 684 | - @ref PAGE_OPT_TRACE | ||
| 685 | - @ref AGGREGATE_CHECKS | ||
| 686 | */ | ||
| 687 | /* clang-format on */ | ||
| 688 | |||
| 689 | #include "sql/mysqld.h" | ||
| 690 | |||
| 691 | #include "my_config.h" | ||
| 692 | |||
| 693 | #include "errmsg.h" // init_client_errs | ||
| 694 | #include "ft_global.h" | ||
| 695 | #ifdef _WIN32 | ||
| 696 | #include "jemalloc_win.h" | ||
| 697 | #endif | ||
| 698 | #include "keycache.h" // KEY_CACHE | ||
| 699 | #include "libbinlogevents/include/binlog_event.h" | ||
| 700 | #include "libbinlogevents/include/control_events.h" | ||
| 701 | #include "m_string.h" | ||
| 702 | #include "migrate_keyring.h" // Migrate_keyring | ||
| 703 | #include "my_alloc.h" | ||
| 704 | #include "my_base.h" | ||
| 705 | #include "my_bitmap.h" // MY_BITMAP | ||
| 706 | #include "my_command.h" | ||
| 707 | #include "my_compiler.h" | ||
| 708 | #include "my_dbug.h" | ||
| 709 | #include "my_default.h" // print_defaults | ||
| 710 | #include "my_dir.h" | ||
| 711 | #include "my_getpwnam.h" | ||
| 712 | #include "my_loglevel.h" | ||
| 713 | #include "my_macros.h" | ||
| 714 | #include "my_shm_defaults.h" // IWYU pragma: keep | ||
| 715 | #include "my_stacktrace.h" // my_set_exception_pointers | ||
| 716 | #include "my_thread_local.h" | ||
| 717 | #include "my_time.h" | ||
| 718 | #include "my_timer.h" // my_timer_initialize | ||
| 719 | #include "myisam.h" | ||
| 720 | #include "mysql/components/services/bits/psi_bits.h" | ||
| 721 | #include "mysql/components/services/log_builtins.h" | ||
| 722 | #include "mysql/components/services/log_shared.h" | ||
| 723 | #include "mysql/components/services/mysql_runtime_error_service.h" | ||
| 724 | #include "mysql/plugin.h" | ||
| 725 | #include "mysql/plugin_audit.h" | ||
| 726 | #include "mysql/psi/mysql_cond.h" | ||
| 727 | #include "mysql/psi/mysql_file.h" | ||
| 728 | #include "mysql/psi/mysql_memory.h" // mysql_memory_init | ||
| 729 | #include "mysql/psi/mysql_mutex.h" | ||
| 730 | #include "mysql/psi/mysql_rwlock.h" | ||
| 731 | #include "mysql/psi/mysql_socket.h" | ||
| 732 | #include "mysql/psi/mysql_stage.h" | ||
| 733 | #include "mysql/psi/mysql_statement.h" | ||
| 734 | #include "mysql/psi/mysql_thread.h" | ||
| 735 | #include "mysql/psi/psi_cond.h" | ||
| 736 | #include "mysql/psi/psi_data_lock.h" | ||
| 737 | #include "mysql/psi/psi_error.h" | ||
| 738 | #include "mysql/psi/psi_file.h" | ||
| 739 | #include "mysql/psi/psi_idle.h" | ||
| 740 | #include "mysql/psi/psi_mdl.h" | ||
| 741 | #include "mysql/psi/psi_memory.h" | ||
| 742 | #include "mysql/psi/psi_mutex.h" | ||
| 743 | #include "mysql/psi/psi_rwlock.h" | ||
| 744 | #include "mysql/psi/psi_socket.h" | ||
| 745 | #include "mysql/psi/psi_stage.h" | ||
| 746 | #include "mysql/psi/psi_statement.h" | ||
| 747 | #include "mysql/psi/psi_system.h" | ||
| 748 | #include "mysql/psi/psi_table.h" | ||
| 749 | #include "mysql/psi/psi_thread.h" | ||
| 750 | #include "mysql/psi/psi_tls_channel.h" | ||
| 751 | #include "mysql/psi/psi_transaction.h" | ||
| 752 | #include "mysql/service_mysql_alloc.h" | ||
| 753 | #include "mysql/thread_type.h" | ||
| 754 | #include "mysql_com.h" | ||
| 755 | #include "mysql_time.h" | ||
| 756 | #include "mysql_version.h" | ||
| 757 | #include "mysqld_error.h" | ||
| 758 | #include "mysys/buffered_error_log.h" | ||
| 759 | #include "mysys_err.h" // EXIT_OUT_OF_MEMORY | ||
| 760 | #include "pfs_thread_provider.h" | ||
| 761 | #include "print_version.h" | ||
| 762 | #include "scope_guard.h" // create_scope_guard() | ||
| 763 | #include "server_component/log_sink_buffer.h" // log_error_stage_set() | ||
| 764 | #include "server_component/log_sink_perfschema.h" // log_error_read_log() | ||
| 765 | #ifdef _WIN32 | ||
| 766 | #include <shellapi.h> | ||
| 767 | #endif | ||
| 768 | #include "sql/auth/auth_common.h" // grant_init | ||
| 769 | #include "sql/auth/sql_authentication.h" // init_rsa_keys | ||
| 770 | #include "sql/auth/sql_security_ctx.h" | ||
| 771 | #include "sql/auto_thd.h" // Auto_THD | ||
| 772 | #include "sql/binlog.h" // mysql_bin_log | ||
| 773 | #include "sql/bootstrap.h" // bootstrap | ||
| 774 | #include "sql/check_stack.h" | ||
| 775 | #include "sql/conn_handler/connection_acceptor.h" // Connection_acceptor | ||
| 776 | #include "sql/conn_handler/connection_handler_impl.h" // Per_thread_connection_handler | ||
| 777 | #include "sql/conn_handler/connection_handler_manager.h" // Connection_handler_manager | ||
| 778 | #include "sql/conn_handler/socket_connection.h" // stmt_info_new_packet | ||
| 779 | #include "sql/current_thd.h" // current_thd | ||
| 780 | #include "sql/dd/cache/dictionary_client.h" | ||
| 781 | #include "sql/debug_sync.h" // debug_sync_end | ||
| 782 | #include "sql/derror.h" | ||
| 783 | #include "sql/event_data_objects.h" // init_scheduler_psi_keys | ||
| 784 | #include "sql/events.h" // Events | ||
| 785 | #include "sql/handler.h" | ||
| 786 | #include "sql/hostname_cache.h" // hostname_cache_init | ||
| 787 | #include "sql/init.h" // unireg_init | ||
| 788 | #include "sql/item.h" | ||
| 789 | #include "sql/item_cmpfunc.h" // Arg_comparator | ||
| 790 | #include "sql/item_create.h" | ||
| 791 | #include "sql/item_func.h" | ||
| 792 | #include "sql/item_strfunc.h" // Item_func_uuid | ||
| 793 | #include "sql/keycaches.h" // get_or_create_key_cache | ||
| 794 | #include "sql/log.h" | ||
| 795 | #include "sql/log_event.h" // Rows_log_event | ||
| 796 | #include "sql/log_resource.h" | ||
| 797 | #include "sql/mdl.h" | ||
| 798 | #include "sql/mdl_context_backup.h" // mdl_context_backup_manager | ||
| 799 | #include "sql/my_decimal.h" | ||
| 800 | #include "sql/mysqld_daemon.h" | ||
| 801 | #include "sql/mysqld_thd_manager.h" // Global_THD_manager | ||
| 802 | #include "sql/opt_costconstantcache.h" // delete_optimizer_cost_module | ||
| 803 | #include "sql/range_optimizer/range_optimizer.h" // range_optimizer_init | ||
| 804 | #include "sql/options_mysqld.h" // OPT_THREAD_CACHE_SIZE | ||
| 805 | #include "sql/partitioning/partition_handler.h" // partitioning_init | ||
| 806 | #include "sql/persisted_variable.h" // Persisted_variables_cache | ||
| 807 | #include "sql/plugin_table.h" | ||
| 808 | #include "sql/protocol.h" | ||
| 809 | #include "sql/psi_memory_key.h" // key_memory_MYSQL_RELAY_LOG_index | ||
| 810 | #include "sql/query_options.h" | ||
| 811 | #include "sql/replication.h" // thd_enter_cond | ||
| 812 | #include "sql/resourcegroups/resource_group_mgr.h" // init, post_init | ||
| 813 | #include "sql/sql_profile.h" | ||
| 814 | #ifdef _WIN32 | ||
| 815 | #include "sql/restart_monitor_win.h" | ||
| 816 | #endif | ||
| 817 | #include "sql/rpl_async_conn_failover_configuration_propagation.h" | ||
| 818 | #include "sql/rpl_event_ctx.h" // Rpl_event_ctx | ||
| 819 | #include "sql/rpl_filter.h" | ||
| 820 | #include "sql/rpl_gtid.h" | ||
| 821 | #include "sql/rpl_gtid_persist.h" // Gtid_table_persistor | ||
| 822 | #include "sql/rpl_handler.h" // RUN_HOOK | ||
| 823 | #include "sql/rpl_info_factory.h" | ||
| 824 | #include "sql/rpl_info_handler.h" | ||
| 825 | #include "sql/rpl_injector.h" // injector | ||
| 826 | #include "sql/rpl_io_monitor.h" | ||
| 827 | #include "sql/rpl_log_encryption.h" | ||
| 828 | #include "sql/rpl_source.h" // max_binlog_dump_events | ||
| 829 | #include "sql/rpl_mi.h" | ||
| 830 | #include "sql/rpl_msr.h" // Multisource_info | ||
| 831 | #include "sql/rpl_rli.h" // Relay_log_info | ||
| 832 | #include "sql/rpl_replica.h" // replica_load_tmpdir | ||
| 833 | #include "sql/rpl_trx_tracking.h" | ||
| 834 | #include "sql/sd_notify.h" // sd_notify_connect | ||
| 835 | #include "sql/session_tracker.h" | ||
| 836 | #include "sql/set_var.h" | ||
| 837 | #include "sql/sp_head.h" // init_sp_psi_keys | ||
| 838 | #include "sql/sql_audit.h" // mysql_audit_general | ||
| 839 | #include "sql/sql_base.h" | ||
| 840 | #include "sql/sql_callback.h" // MUSQL_CALLBACK | ||
| 841 | #include "sql/sql_class.h" // THD | ||
| 842 | #include "sql/sql_component.h" | ||
| 843 | #include "sql/sql_connect.h" | ||
| 844 | #include "sql/sql_error.h" | ||
| 845 | #include "sql/sql_initialize.h" // opt_initialize_insecure | ||
| 846 | #include "sql/sql_lex.h" | ||
| 847 | #include "sql/sql_list.h" | ||
| 848 | #include "sql/sql_locale.h" // MY_LOCALE | ||
| 849 | #include "sql/sql_manager.h" // start_handle_manager | ||
| 850 | #include "sql/sql_parse.h" // check_stack_overrun | ||
| 851 | #include "sql/sql_plugin.h" // opt_plugin_dir | ||
| 852 | #include "sql/sql_plugin_ref.h" | ||
| 853 | #include "sql/sql_reload.h" // handle_reload_request | ||
| 854 | #include "sql/sql_restart_server.h" // is_mysqld_managed | ||
| 855 | #include "sql/sql_servers.h" | ||
| 856 | #include "sql/sql_show.h" | ||
| 857 | #include "sql/sql_table.h" // build_table_filename | ||
| 858 | #include "sql/sql_udf.h" | ||
| 859 | #include "sql/ssl_acceptor_context_iterator.h" | ||
| 860 | #include "sql/ssl_acceptor_context_operator.h" | ||
| 861 | #include "sql/ssl_acceptor_context_status.h" | ||
| 862 | #include "sql/ssl_init_callback.h" | ||
| 863 | #include "sql/sys_vars.h" // fixup_enforce_gtid_consistency_... | ||
| 864 | #include "sql/sys_vars_shared.h" // intern_find_sys_var | ||
| 865 | #include "sql/table_cache.h" // table_cache_manager | ||
| 866 | #include "sql/tc_log.h" // tc_log | ||
| 867 | #include "sql/thd_raii.h" | ||
| 868 | #include "sql/thr_malloc.h" | ||
| 869 | #include "sql/threadpool.h" | ||
| 870 | #include "sql/transaction.h" | ||
| 871 | #include "sql/tztime.h" // Time_zone | ||
| 872 | #include "sql/udf_service_impl.h" | ||
| 873 | #include "sql/xa.h" | ||
| 874 | #include "sql/xa/transaction_cache.h" // xa::Transaction_cache | ||
| 875 | #include "sql_common.h" // mysql_client_plugin_init | ||
| 876 | #include "sql_string.h" | ||
| 877 | #include "storage/myisam/ha_myisam.h" // HA_RECOVER_OFF | ||
| 878 | #include "storage/perfschema/pfs_services.h" | ||
| 879 | #include "thr_lock.h" | ||
| 880 | #include "thr_mutex.h" | ||
| 881 | #include "typelib.h" | ||
| 882 | #include "violite.h" | ||
| 883 | #include "my_openssl_fips.h" // OPENSSL_ERROR_LENGTH, set_fips_mode | ||
| 884 | |||
| 885 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 886 | #include "storage/perfschema/pfs_server.h" | ||
| 887 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 888 | |||
| 889 | #ifdef _WIN32 | ||
| 890 | #include "sql/conn_handler/named_pipe_connection.h" | ||
| 891 | #include "sql/conn_handler/shared_memory_connection.h" | ||
| 892 | #include "sql/named_pipe.h" | ||
| 893 | #endif | ||
| 894 | |||
| 895 | #ifdef HAVE_ARPA_INET_H | ||
| 896 | #include <arpa/inet.h> | ||
| 897 | #endif | ||
| 898 | #ifdef MY_MSCRT_DEBUG | ||
| 899 | #include <crtdbg.h> | ||
| 900 | #endif | ||
| 901 | #include <errno.h> | ||
| 902 | #include <fcntl.h> | ||
| 903 | #include <fenv.h> | ||
| 904 | #include <limits.h> | ||
| 905 | #ifdef HAVE_GRP_H | ||
| 906 | #include <grp.h> | ||
| 907 | #endif | ||
| 908 | #ifndef _WIN32 | ||
| 909 | #include <netdb.h> | ||
| 910 | #endif | ||
| 911 | #ifdef HAVE_NETINET_IN_H | ||
| 912 | #include <netinet/in.h> | ||
| 913 | #endif | ||
| 914 | #include <signal.h> | ||
| 915 | #include <stdarg.h> | ||
| 916 | #include <stddef.h> | ||
| 917 | #include <stdio.h> | ||
| 918 | #include <stdlib.h> | ||
| 919 | #include <string.h> | ||
| 920 | #include <sys/types.h> | ||
| 921 | #ifdef HAVE_SYS_MMAN_H | ||
| 922 | #include <sys/mman.h> | ||
| 923 | #endif | ||
| 924 | #ifdef HAVE_SYS_PRCTL_H | ||
| 925 | #include <sys/prctl.h> | ||
| 926 | #endif | ||
| 927 | #ifdef HAVE_SYS_RESOURCE_H | ||
| 928 | #include <sys/resource.h> | ||
| 929 | #endif | ||
| 930 | #include <sys/stat.h> | ||
| 931 | #ifdef HAVE_UNISTD_H | ||
| 932 | #include <unistd.h> | ||
| 933 | #endif | ||
| 934 | #ifdef _WIN32 | ||
| 935 | #include <crtdbg.h> | ||
| 936 | #include <process.h> | ||
| 937 | #endif | ||
| 938 | #include "unicode/putil.h" // u_setDataDirectory() | ||
| 939 | #include "unicode/uclean.h" // u_cleanup() | ||
| 940 | |||
| 941 | #include <algorithm> | ||
| 942 | #include <atomic> | ||
| 943 | #include <functional> | ||
| 944 | #include <new> | ||
| 945 | |||
| 946 | #ifndef EMBEDDED_LIBRARY | ||
| 947 | #ifdef WITH_LOCK_ORDER | ||
| 948 | #include "sql/debug_lock_order.h" | ||
| 949 | #endif /* WITH_LOCK_ORDER */ | ||
| 950 | #endif /* EMBEDDED_LIBRARY */ | ||
| 951 | |||
| 952 | #ifndef EMBEDDED_LIBRARY | ||
| 953 | #include "srv_session.h" | ||
| 954 | #endif | ||
| 955 | |||
| 956 | #include <mysql/components/minimal_chassis.h> | ||
| 957 | #include <mysql/components/services/dynamic_loader_scheme_file.h> | ||
| 958 | #include <mysql/components/services/mysql_psi_system_service.h> | ||
| 959 | #include <mysql/components/services/mysql_rwlock_service.h> | ||
| 960 | #include <mysql/components/services/ongoing_transaction_query_service.h> | ||
| 961 | #include "sql/auth/dynamic_privileges_impl.h" | ||
| 962 | #include "sql/dd/dd.h" // dd::shutdown | ||
| 963 | #include "sql/dd/dd_kill_immunizer.h" // dd::DD_kill_immunizer | ||
| 964 | #include "sql/dd/dictionary.h" // dd::get_dictionary | ||
| 965 | #include "sql/dd/ndbinfo_schema/init.h" // dd::ndbinfo::init_schema_and_tables() | ||
| 966 | #include "sql/dd/performance_schema/init.h" // performance_schema::init | ||
| 967 | #include "sql/dd/upgrade/server.h" // dd::upgrade::upgrade_system_schemas | ||
| 968 | #include "sql/dd/upgrade_57/upgrade.h" // dd::upgrade_57::in_progress | ||
| 969 | #include "sql/server_component/component_sys_var_service_imp.h" | ||
| 970 | #include "sql/server_component/log_builtins_filter_imp.h" | ||
| 971 | #include "sql/server_component/log_builtins_imp.h" | ||
| 972 | #include "sql/server_component/mysql_server_keyring_lockable_imp.h" | ||
| 973 | #include "sql/server_component/persistent_dynamic_loader_imp.h" | ||
| 974 | #include "sql/srv_session.h" | ||
| 975 | |||
| 976 | using std::max; | ||
| 977 | using std::min; | ||
| 978 | using std::vector; | ||
| 979 | |||
| 980 | #define mysqld_charset &my_charset_latin1 | ||
| 981 | #define mysqld_default_locale_name "en_US" | ||
| 982 | |||
| 983 | #ifdef HAVE_FPU_CONTROL_H | ||
| 984 | #include <fpu_control.h> // IWYU pragma: keep | ||
| 985 | #elif defined(__i386__) | ||
| 986 | #define fpu_control_t unsigned int | ||
| 987 | #define _FPU_EXTENDED 0x300 | ||
| 988 | #define _FPU_DOUBLE 0x200 | ||
| 989 | #if defined(__GNUC__) | ||
| 990 | #define _FPU_GETCW(cw) asm volatile("fnstcw %0" : "=m"(*&cw)) | ||
| 991 | #define _FPU_SETCW(cw) asm volatile("fldcw %0" : : "m"(*&cw)) | ||
| 992 | #else | ||
| 993 | #define _FPU_GETCW(cw) (cw = 0) | ||
| 994 | #define _FPU_SETCW(cw) | ||
| 995 | #endif | ||
| 996 | #endif | ||
| 997 | 12058 | inline void setup_fpu() { | |
| 998 | #ifdef HAVE_FEDISABLEEXCEPT | ||
| 999 | 12058 | fedisableexcept(FE_ALL_EXCEPT); | |
| 1000 | #endif | ||
| 1001 | |||
| 1002 | /* Set FPU rounding mode to "round-to-nearest" */ | ||
| 1003 | 12058 | fesetround(FE_TONEAREST); | |
| 1004 | |||
| 1005 | /* | ||
| 1006 | x86 (32-bit) requires FPU precision to be explicitly set to 64 bit | ||
| 1007 | (double precision) for portable results of floating point operations. | ||
| 1008 | However, there is no need to do so if compiler is using SSE2 for floating | ||
| 1009 | point, double values will be stored and processed in 64 bits anyway. | ||
| 1010 | */ | ||
| 1011 | #if defined(__i386__) && !defined(__SSE2_MATH__) | ||
| 1012 | #if !defined(_WIN32) | ||
| 1013 | fpu_control_t cw; | ||
| 1014 | _FPU_GETCW(cw); | ||
| 1015 | cw = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; | ||
| 1016 | _FPU_SETCW(cw); | ||
| 1017 | #endif /* _WIN32 && */ | ||
| 1018 | #endif /* __i386__ */ | ||
| 1019 | 12058 | } | |
| 1020 | |||
| 1021 | extern "C" void handle_fatal_signal(int sig); | ||
| 1022 | void my_server_abort(); | ||
| 1023 | |||
| 1024 | /* Constants */ | ||
| 1025 | |||
| 1026 | #include "welcome_copyright_notice.h" // ORACLE_WELCOME_COPYRIGHT_NOTICE | ||
| 1027 | |||
| 1028 | const char *show_comp_option_name[] = {"YES", "NO", "DISABLED"}; | ||
| 1029 | |||
| 1030 | static const char *tc_heuristic_recover_names[] = {"OFF", "COMMIT", "ROLLBACK", | ||
| 1031 | NullS}; | ||
| 1032 | static TYPELIB tc_heuristic_recover_typelib = { | ||
| 1033 | array_elements(tc_heuristic_recover_names) - 1, "", | ||
| 1034 | tc_heuristic_recover_names, nullptr}; | ||
| 1035 | |||
| 1036 | const char *first_keyword = "first", *binary_keyword = "BINARY"; | ||
| 1037 | const char *my_localhost = "localhost"; | ||
| 1038 | |||
| 1039 | bool opt_large_files = sizeof(my_off_t) > 4; | ||
| 1040 | static bool opt_autocommit; ///< for --autocommit command-line option | ||
| 1041 | static get_opt_arg_source source_autocommit; | ||
| 1042 | |||
| 1043 | /* | ||
| 1044 | Used with --help for detailed option | ||
| 1045 | */ | ||
| 1046 | bool opt_help = false, opt_verbose = false, opt_validate_config = false; | ||
| 1047 | |||
| 1048 | arg_cmp_func Arg_comparator::comparator_matrix[5] = { | ||
| 1049 | &Arg_comparator::compare_string, // Compare strings | ||
| 1050 | &Arg_comparator::compare_real, // Compare float values | ||
| 1051 | &Arg_comparator::compare_int_signed, // Compare signed int values | ||
| 1052 | &Arg_comparator::compare_row, // Compare row values | ||
| 1053 | &Arg_comparator::compare_decimal}; // Compare decimal values | ||
| 1054 | |||
| 1055 | PSI_file_key key_file_binlog_cache; | ||
| 1056 | PSI_file_key key_file_binlog_index_cache; | ||
| 1057 | |||
| 1058 | #ifdef HAVE_PSI_INTERFACE | ||
| 1059 | static PSI_mutex_key key_LOCK_status; | ||
| 1060 | static PSI_mutex_key key_LOCK_manager; | ||
| 1061 | static PSI_mutex_key key_LOCK_crypt; | ||
| 1062 | static PSI_mutex_key key_LOCK_user_conn; | ||
| 1063 | static PSI_mutex_key key_LOCK_global_system_variables; | ||
| 1064 | static PSI_mutex_key key_LOCK_prepared_stmt_count; | ||
| 1065 | static PSI_mutex_key key_LOCK_replica_list; | ||
| 1066 | static PSI_mutex_key key_LOCK_sql_replica_skip_counter; | ||
| 1067 | static PSI_mutex_key key_LOCK_replica_net_timeout; | ||
| 1068 | static PSI_mutex_key key_LOCK_replica_trans_dep_tracker; | ||
| 1069 | static PSI_mutex_key key_LOCK_uuid_generator; | ||
| 1070 | static PSI_mutex_key key_LOCK_error_messages; | ||
| 1071 | static PSI_mutex_key key_LOCK_default_password_lifetime; | ||
| 1072 | static PSI_mutex_key key_LOCK_mandatory_roles; | ||
| 1073 | static PSI_mutex_key key_LOCK_password_history; | ||
| 1074 | static PSI_mutex_key key_LOCK_password_reuse_interval; | ||
| 1075 | static PSI_mutex_key key_LOCK_sql_rand; | ||
| 1076 | static PSI_mutex_key key_LOCK_log_throttle_qni; | ||
| 1077 | static PSI_mutex_key key_LOCK_reset_gtid_table; | ||
| 1078 | static PSI_mutex_key key_LOCK_compress_gtid_table; | ||
| 1079 | static PSI_mutex_key key_LOCK_collect_instance_log; | ||
| 1080 | static PSI_mutex_key key_BINLOG_LOCK_commit; | ||
| 1081 | static PSI_mutex_key key_BINLOG_LOCK_commit_queue; | ||
| 1082 | static PSI_mutex_key key_BINLOG_LOCK_done; | ||
| 1083 | static PSI_mutex_key key_BINLOG_LOCK_flush_queue; | ||
| 1084 | static PSI_mutex_key key_BINLOG_LOCK_index; | ||
| 1085 | static PSI_mutex_key key_BINLOG_LOCK_log; | ||
| 1086 | static PSI_mutex_key key_BINLOG_LOCK_binlog_end_pos; | ||
| 1087 | static PSI_mutex_key key_BINLOG_LOCK_sync; | ||
| 1088 | static PSI_mutex_key key_BINLOG_LOCK_sync_queue; | ||
| 1089 | static PSI_mutex_key key_BINLOG_LOCK_xids; | ||
| 1090 | static PSI_rwlock_key key_rwlock_global_sid_lock; | ||
| 1091 | PSI_rwlock_key key_rwlock_gtid_mode_lock; | ||
| 1092 | static PSI_rwlock_key key_rwlock_LOCK_system_variables_hash; | ||
| 1093 | static PSI_rwlock_key key_rwlock_LOCK_sys_init_connect; | ||
| 1094 | static PSI_rwlock_key key_rwlock_LOCK_sys_init_replica; | ||
| 1095 | static PSI_cond_key key_BINLOG_COND_done; | ||
| 1096 | static PSI_cond_key key_BINLOG_COND_flush_queue; | ||
| 1097 | static PSI_cond_key key_BINLOG_update_cond; | ||
| 1098 | static PSI_cond_key key_BINLOG_prep_xids_cond; | ||
| 1099 | static PSI_cond_key key_COND_manager; | ||
| 1100 | static PSI_cond_key key_COND_compress_gtid_table; | ||
| 1101 | static PSI_thread_key key_thread_signal_hand; | ||
| 1102 | static PSI_thread_key key_thread_main; | ||
| 1103 | static PSI_file_key key_file_casetest; | ||
| 1104 | static PSI_file_key key_file_pid; | ||
| 1105 | #if defined(_WIN32) | ||
| 1106 | static PSI_thread_key key_thread_handle_con_namedpipes; | ||
| 1107 | static PSI_thread_key key_thread_handle_con_sharedmem; | ||
| 1108 | static PSI_thread_key key_thread_handle_con_sockets; | ||
| 1109 | static PSI_mutex_key key_LOCK_handler_count; | ||
| 1110 | static PSI_cond_key key_COND_handler_count; | ||
| 1111 | static PSI_thread_key key_thread_handle_shutdown_restart; | ||
| 1112 | static PSI_rwlock_key key_rwlock_LOCK_named_pipe_full_access_group; | ||
| 1113 | #else | ||
| 1114 | static PSI_mutex_key key_LOCK_socket_listener_active; | ||
| 1115 | static PSI_cond_key key_COND_socket_listener_active; | ||
| 1116 | static PSI_mutex_key key_LOCK_start_signal_handler; | ||
| 1117 | static PSI_cond_key key_COND_start_signal_handler; | ||
| 1118 | #endif // _WIN32 | ||
| 1119 | static PSI_mutex_key key_LOCK_server_started; | ||
| 1120 | static PSI_cond_key key_COND_server_started; | ||
| 1121 | static PSI_mutex_key key_LOCK_keyring_operations; | ||
| 1122 | static PSI_mutex_key key_LOCK_tls_ctx_options; | ||
| 1123 | static PSI_mutex_key key_LOCK_admin_tls_ctx_options; | ||
| 1124 | static PSI_mutex_key key_LOCK_rotate_binlog_master_key; | ||
| 1125 | static PSI_mutex_key key_LOCK_partial_revokes; | ||
| 1126 | static PSI_mutex_key key_LOCK_authentication_policy; | ||
| 1127 | static PSI_mutex_key key_LOCK_global_conn_mem_limit; | ||
| 1128 | #endif /* HAVE_PSI_INTERFACE */ | ||
| 1129 | |||
| 1130 | /** | ||
| 1131 | Statement instrumentation key for replication. | ||
| 1132 | */ | ||
| 1133 | #ifdef HAVE_PSI_STATEMENT_INTERFACE | ||
| 1134 | PSI_statement_info stmt_info_rpl; | ||
| 1135 | #endif | ||
| 1136 | |||
| 1137 | /* the default log output is log tables */ | ||
| 1138 | static bool lower_case_table_names_used = false; | ||
| 1139 | #if !defined(_WIN32) | ||
| 1140 | static bool socket_listener_active = false; | ||
| 1141 | static int pipe_write_fd = -1; | ||
| 1142 | static bool opt_daemonize = false; | ||
| 1143 | #endif | ||
| 1144 | bool opt_debugging = false; | ||
| 1145 | static bool opt_external_locking = false, opt_console = false; | ||
| 1146 | static bool opt_short_log_format = false; | ||
| 1147 | static char *mysqld_user, *mysqld_chroot; | ||
| 1148 | static const char *default_character_set_name; | ||
| 1149 | static const char *character_set_filesystem_name; | ||
| 1150 | static const char *lc_messages; | ||
| 1151 | static const char *lc_time_names_name; | ||
| 1152 | char *my_bind_addr_str; | ||
| 1153 | char *my_admin_bind_addr_str; | ||
| 1154 | uint mysqld_admin_port; | ||
| 1155 | bool listen_admin_interface_in_separate_thread; | ||
| 1156 | char *my_proxy_protocol_networks; | ||
| 1157 | static const char *default_collation_name; | ||
| 1158 | const char *default_storage_engine; | ||
| 1159 | const char *default_tmp_storage_engine; | ||
| 1160 | ulonglong temptable_max_ram; | ||
| 1161 | ulonglong temptable_max_mmap; | ||
| 1162 | bool temptable_use_mmap; | ||
| 1163 | static char compiled_default_collation_name[] = MYSQL_DEFAULT_COLLATION_NAME; | ||
| 1164 | static bool binlog_format_used = false; | ||
| 1165 | |||
| 1166 | LEX_STRING opt_init_connect, opt_init_replica; | ||
| 1167 | |||
| 1168 | /* Global variables */ | ||
| 1169 | |||
| 1170 | LEX_STRING opt_mandatory_roles; | ||
| 1171 | bool opt_mandatory_roles_cache = false; | ||
| 1172 | bool opt_always_activate_granted_roles = false; | ||
| 1173 | bool opt_bin_log; | ||
| 1174 | bool opt_general_log, opt_slow_log, opt_general_log_raw; | ||
| 1175 | ulonglong slow_query_log_always_write_time = 10000000; | ||
| 1176 | ulonglong log_output_options; | ||
| 1177 | bool opt_log_queries_not_using_indexes = false; | ||
| 1178 | ulong opt_log_throttle_queries_not_using_indexes = 0; | ||
| 1179 | bool opt_log_slow_extra = false; | ||
| 1180 | bool opt_disable_networking = false, opt_skip_show_db = false; | ||
| 1181 | bool opt_skip_name_resolve = false; | ||
| 1182 | bool opt_character_set_client_handshake = true; | ||
| 1183 | bool server_id_supplied = false; | ||
| 1184 | static bool opt_endinfo; | ||
| 1185 | bool using_udf_functions; | ||
| 1186 | bool locked_in_memory; | ||
| 1187 | bool opt_using_transactions; | ||
| 1188 | ulong opt_tc_log_size; | ||
| 1189 | std::atomic<int32> connection_events_loop_aborted_flag; | ||
| 1190 | static std::atomic<enum_server_operational_state> server_operational_state{ | ||
| 1191 | SERVER_BOOTING}; | ||
| 1192 | char *opt_log_error_suppression_list; | ||
| 1193 | char *opt_log_error_services; | ||
| 1194 | char *opt_keyring_migration_user = nullptr; | ||
| 1195 | char *opt_keyring_migration_host = nullptr; | ||
| 1196 | char *opt_keyring_migration_password = nullptr; | ||
| 1197 | char *opt_keyring_migration_socket = nullptr; | ||
| 1198 | char *opt_keyring_migration_source = nullptr; | ||
| 1199 | char *opt_keyring_migration_destination = nullptr; | ||
| 1200 | ulong opt_keyring_migration_port = 0; | ||
| 1201 | bool migrate_connect_options = false; | ||
| 1202 | uint host_cache_size; | ||
| 1203 | ulong log_error_verbosity = 3; // have a non-zero value during early start-up | ||
| 1204 | bool opt_keyring_migration_to_component = false; | ||
| 1205 | bool opt_libcoredumper, opt_corefile = 0; | ||
| 1206 | bool opt_persist_sensitive_variables_in_plaintext{true}; | ||
| 1207 | |||
| 1208 | #if defined(_WIN32) | ||
| 1209 | /* | ||
| 1210 | Thread handle of shutdown event handler thread. | ||
| 1211 | It is used as argument during thread join. | ||
| 1212 | */ | ||
| 1213 | my_thread_handle shutdown_restart_thr_handle; | ||
| 1214 | |||
| 1215 | ulong slow_start_timeout; | ||
| 1216 | bool opt_no_monitor = false; | ||
| 1217 | #endif | ||
| 1218 | |||
| 1219 | bool opt_no_dd_upgrade = false; | ||
| 1220 | long opt_upgrade_mode = UPGRADE_AUTO; | ||
| 1221 | bool opt_initialize = false; | ||
| 1222 | bool dd_init_failed_during_upgrade = false; | ||
| 1223 | bool opt_skip_replica_start = false; ///< If set, slave is not autostarted | ||
| 1224 | bool opt_enable_named_pipe = false; | ||
| 1225 | bool opt_local_infile, opt_replica_compressed_protocol; | ||
| 1226 | bool opt_safe_user_create = false; | ||
| 1227 | bool opt_show_replica_auth_info; | ||
| 1228 | bool opt_log_replica_updates = false; | ||
| 1229 | char *opt_replica_skip_errors; | ||
| 1230 | bool opt_replica_allow_batching = true; | ||
| 1231 | |||
| 1232 | /** | ||
| 1233 | compatibility option: | ||
| 1234 | - index usage hints (USE INDEX without a FOR clause) behave as in 5.0 | ||
| 1235 | */ | ||
| 1236 | bool old_mode; | ||
| 1237 | |||
| 1238 | /* | ||
| 1239 | Legacy global handlerton. These will be removed (please do not add more). | ||
| 1240 | */ | ||
| 1241 | handlerton *heap_hton; | ||
| 1242 | handlerton *temptable_hton; | ||
| 1243 | handlerton *myisam_hton; | ||
| 1244 | handlerton *innodb_hton; | ||
| 1245 | |||
| 1246 | char *opt_disabled_storage_engines; | ||
| 1247 | uint opt_server_id_bits = 0; | ||
| 1248 | ulong opt_server_id_mask = 0; | ||
| 1249 | bool read_only = false, opt_readonly = false; | ||
| 1250 | bool super_read_only = false, opt_super_readonly = false; | ||
| 1251 | bool opt_require_secure_transport = false; | ||
| 1252 | bool relay_log_purge; | ||
| 1253 | bool relay_log_recovery; | ||
| 1254 | bool opt_allow_suspicious_udfs; | ||
| 1255 | const char *opt_secure_file_priv; | ||
| 1256 | const char *opt_secure_log_path; | ||
| 1257 | bool opt_log_slow_admin_statements = false; | ||
| 1258 | bool opt_log_slow_replica_statements = false; | ||
| 1259 | bool lower_case_file_system = false; | ||
| 1260 | bool opt_large_pages = false; | ||
| 1261 | bool opt_super_large_pages = false; | ||
| 1262 | bool opt_myisam_use_mmap = false; | ||
| 1263 | std::atomic<bool> offline_mode; | ||
| 1264 | uint opt_large_page_size = 0; | ||
| 1265 | uint default_password_lifetime = 0; | ||
| 1266 | ulonglong opt_slow_query_log_use_global_control = 0; | ||
| 1267 | ulong opt_slow_query_log_rate_type = 0; | ||
| 1268 | bool password_require_current = false; | ||
| 1269 | std::atomic<bool> partial_revokes; | ||
| 1270 | bool opt_partial_revokes; // Initialized through Sys_var | ||
| 1271 | |||
| 1272 | mysql_mutex_t LOCK_default_password_lifetime; | ||
| 1273 | mysql_mutex_t LOCK_mandatory_roles; | ||
| 1274 | mysql_mutex_t LOCK_password_history; | ||
| 1275 | mysql_mutex_t LOCK_password_reuse_interval; | ||
| 1276 | mysql_mutex_t LOCK_tls_ctx_options; | ||
| 1277 | mysql_mutex_t LOCK_admin_tls_ctx_options; | ||
| 1278 | mysql_mutex_t LOCK_partial_revokes; | ||
| 1279 | |||
| 1280 | #if defined(ENABLED_DEBUG_SYNC) | ||
| 1281 | MYSQL_PLUGIN_IMPORT uint opt_debug_sync_timeout = 0; | ||
| 1282 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 1283 | bool opt_old_style_user_limits = false, trust_function_creators = false; | ||
| 1284 | bool check_proxy_users = false, mysql_native_password_proxy_users = false, | ||
| 1285 | sha256_password_proxy_users = false; | ||
| 1286 | bool opt_userstat = false; | ||
| 1287 | bool opt_thread_statistics = false; | ||
| 1288 | /* | ||
| 1289 | True if there is at least one per-hour limit for some user, so we should | ||
| 1290 | check them before each query (and possibly reset counters when hour is | ||
| 1291 | changed). False otherwise. | ||
| 1292 | */ | ||
| 1293 | volatile bool mqh_used = false; | ||
| 1294 | bool opt_noacl = false; | ||
| 1295 | bool sp_automatic_privileges = true; | ||
| 1296 | |||
| 1297 | int32_t opt_regexp_time_limit; | ||
| 1298 | int32_t opt_regexp_stack_limit; | ||
| 1299 | |||
| 1300 | /** True, if restarted from a cloned database. This information | ||
| 1301 | is needed by GR to set some configurations right after clone. */ | ||
| 1302 | bool clone_startup = false; | ||
| 1303 | |||
| 1304 | /** True, if clone recovery has failed. For managed server we | ||
| 1305 | restart server again with old database files. */ | ||
| 1306 | bool clone_recovery_error = false; | ||
| 1307 | |||
| 1308 | ulong binlog_row_event_max_size; | ||
| 1309 | ulong binlog_checksum_options; | ||
| 1310 | ulong binlog_row_metadata; | ||
| 1311 | bool opt_source_verify_checksum = false; | ||
| 1312 | bool opt_replica_sql_verify_checksum = true; | ||
| 1313 | const char *binlog_format_names[] = {"MIXED", "STATEMENT", "ROW", NullS}; | ||
| 1314 | bool binlog_gtid_simple_recovery; | ||
| 1315 | ulong binlog_error_action; | ||
| 1316 | const char *binlog_error_action_list[] = {"IGNORE_ERROR", "ABORT_SERVER", | ||
| 1317 | NullS}; | ||
| 1318 | bool opt_binlog_skip_flush_commands = false; | ||
| 1319 | uint32 gtid_executed_compression_period = 0; | ||
| 1320 | bool opt_log_unsafe_statements; | ||
| 1321 | |||
| 1322 | const char *timestamp_type_names[] = {"UTC", "SYSTEM", NullS}; | ||
| 1323 | ulong opt_log_timestamps; | ||
| 1324 | uint mysqld_port, test_flags = 0, select_errors, ha_open_options; | ||
| 1325 | uint mysqld_port_timeout; | ||
| 1326 | ulong delay_key_write_options; | ||
| 1327 | uint protocol_version; | ||
| 1328 | uint lower_case_table_names; | ||
| 1329 | long tc_heuristic_recover; | ||
| 1330 | ulong back_log, connect_timeout, server_id; | ||
| 1331 | ulong table_cache_size; | ||
| 1332 | ulong table_cache_instances; | ||
| 1333 | ulong table_cache_size_per_instance; | ||
| 1334 | ulong schema_def_size; | ||
| 1335 | ulong stored_program_def_size; | ||
| 1336 | ulong table_def_size; | ||
| 1337 | ulong tablespace_def_size; | ||
| 1338 | ulong what_to_log; | ||
| 1339 | ulong slow_launch_time; | ||
| 1340 | std::atomic<int32> atomic_replica_open_temp_tables{0}; | ||
| 1341 | ulong open_files_limit, max_binlog_size, max_relay_log_size; | ||
| 1342 | ulong slave_trans_retries; | ||
| 1343 | uint replica_net_timeout; | ||
| 1344 | ulong replica_exec_mode_options; | ||
| 1345 | ulonglong replica_type_conversions_options; | ||
| 1346 | ulong opt_mts_replica_parallel_workers; | ||
| 1347 | ulonglong opt_mts_pending_jobs_size_max; | ||
| 1348 | ulonglong slave_rows_search_algorithms_options; | ||
| 1349 | bool opt_replica_preserve_commit_order; | ||
| 1350 | #ifndef NDEBUG | ||
| 1351 | uint replica_rows_last_search_algorithm_used; | ||
| 1352 | #endif | ||
| 1353 | ulong mts_parallel_option; | ||
| 1354 | ulong binlog_cache_size = 0; | ||
| 1355 | ulonglong max_binlog_cache_size = 0; | ||
| 1356 | ulong net_buffer_shrink_interval = 0; | ||
| 1357 | ulong replica_max_allowed_packet = 0; | ||
| 1358 | ulong binlog_stmt_cache_size = 0; | ||
| 1359 | int32 opt_binlog_max_flush_queue_time = 0; | ||
| 1360 | long opt_binlog_group_commit_sync_delay = 0; | ||
| 1361 | ulong opt_binlog_group_commit_sync_no_delay_count = 0; | ||
| 1362 | ulonglong max_binlog_stmt_cache_size = 0; | ||
| 1363 | ulong refresh_version; /* Increments on each reload */ | ||
| 1364 | std::atomic<query_id_t> atomic_global_query_id{1}; | ||
| 1365 | ulong aborted_threads; | ||
| 1366 | ulong delayed_insert_timeout, delayed_insert_limit, delayed_queue_size; | ||
| 1367 | ulong delayed_insert_threads, delayed_insert_writes, delayed_rows_in_use; | ||
| 1368 | ulong delayed_insert_errors, flush_time; | ||
| 1369 | ulong specialflag = 0; | ||
| 1370 | ulong binlog_cache_use = 0, binlog_cache_disk_use = 0; | ||
| 1371 | ulong binlog_stmt_cache_use = 0, binlog_stmt_cache_disk_use = 0; | ||
| 1372 | ulong max_connections, max_connect_errors; | ||
| 1373 | ulong rpl_stop_replica_timeout = LONG_TIMEOUT; | ||
| 1374 | bool log_bin_use_v1_row_events = false; | ||
| 1375 | bool thread_cache_size_specified = false; | ||
| 1376 | bool host_cache_size_specified = false; | ||
| 1377 | bool table_definition_cache_specified = false; | ||
| 1378 | ulong locked_account_connection_count = 0; | ||
| 1379 | |||
| 1380 | ulonglong denied_connections = 0; | ||
| 1381 | ulonglong global_conn_mem_limit = 0; | ||
| 1382 | ulonglong global_conn_mem_counter = 0; | ||
| 1383 | |||
| 1384 | /** | ||
| 1385 | This variable holds handle to the object that's responsible | ||
| 1386 | for loading/unloading components from manifest file | ||
| 1387 | */ | ||
| 1388 | Deployed_components *g_deployed_components = nullptr; | ||
| 1389 | |||
| 1390 | /** | ||
| 1391 | Limit of the total number of prepared statements in the server. | ||
| 1392 | Is necessary to protect the server against out-of-memory attacks. | ||
| 1393 | */ | ||
| 1394 | ulong max_prepared_stmt_count; | ||
| 1395 | /** | ||
| 1396 | Current total number of prepared statements in the server. This number | ||
| 1397 | is exact, and therefore may not be equal to the difference between | ||
| 1398 | `com_stmt_prepare' and `com_stmt_close' (global status variables), as | ||
| 1399 | the latter ones account for all registered attempts to prepare | ||
| 1400 | a statement (including unsuccessful ones). Prepared statements are | ||
| 1401 | currently connection-local: if the same SQL query text is prepared in | ||
| 1402 | two different connections, this counts as two distinct prepared | ||
| 1403 | statements. | ||
| 1404 | */ | ||
| 1405 | ulong prepared_stmt_count = 0; | ||
| 1406 | ulong current_pid; | ||
| 1407 | uint sync_binlog_period = 0, sync_relaylog_period = 0, | ||
| 1408 | sync_relayloginfo_period = 0, sync_masterinfo_period = 0, | ||
| 1409 | opt_mta_checkpoint_period, opt_mta_checkpoint_group; | ||
| 1410 | ulong expire_logs_days = 0; | ||
| 1411 | ulong binlog_expire_logs_seconds = 0; | ||
| 1412 | bool opt_binlog_expire_logs_auto_purge{true}; | ||
| 1413 | /** | ||
| 1414 | Soft upper limit for number of sp_head objects that can be stored | ||
| 1415 | in the sp_cache for one connection. | ||
| 1416 | */ | ||
| 1417 | ulong stored_program_cache_size = 0; | ||
| 1418 | /** | ||
| 1419 | Compatibility option to prevent auto upgrade of old temporals | ||
| 1420 | during certain ALTER TABLE operations. | ||
| 1421 | */ | ||
| 1422 | bool avoid_temporal_upgrade; | ||
| 1423 | |||
| 1424 | bool persisted_globals_load = true; | ||
| 1425 | |||
| 1426 | bool opt_keyring_operations = true; | ||
| 1427 | |||
| 1428 | bool opt_table_encryption_privilege_check = false; | ||
| 1429 | |||
| 1430 | const double log_10[] = { | ||
| 1431 | 1e000, 1e001, 1e002, 1e003, 1e004, 1e005, 1e006, 1e007, 1e008, 1e009, 1e010, | ||
| 1432 | 1e011, 1e012, 1e013, 1e014, 1e015, 1e016, 1e017, 1e018, 1e019, 1e020, 1e021, | ||
| 1433 | 1e022, 1e023, 1e024, 1e025, 1e026, 1e027, 1e028, 1e029, 1e030, 1e031, 1e032, | ||
| 1434 | 1e033, 1e034, 1e035, 1e036, 1e037, 1e038, 1e039, 1e040, 1e041, 1e042, 1e043, | ||
| 1435 | 1e044, 1e045, 1e046, 1e047, 1e048, 1e049, 1e050, 1e051, 1e052, 1e053, 1e054, | ||
| 1436 | 1e055, 1e056, 1e057, 1e058, 1e059, 1e060, 1e061, 1e062, 1e063, 1e064, 1e065, | ||
| 1437 | 1e066, 1e067, 1e068, 1e069, 1e070, 1e071, 1e072, 1e073, 1e074, 1e075, 1e076, | ||
| 1438 | 1e077, 1e078, 1e079, 1e080, 1e081, 1e082, 1e083, 1e084, 1e085, 1e086, 1e087, | ||
| 1439 | 1e088, 1e089, 1e090, 1e091, 1e092, 1e093, 1e094, 1e095, 1e096, 1e097, 1e098, | ||
| 1440 | 1e099, 1e100, 1e101, 1e102, 1e103, 1e104, 1e105, 1e106, 1e107, 1e108, 1e109, | ||
| 1441 | 1e110, 1e111, 1e112, 1e113, 1e114, 1e115, 1e116, 1e117, 1e118, 1e119, 1e120, | ||
| 1442 | 1e121, 1e122, 1e123, 1e124, 1e125, 1e126, 1e127, 1e128, 1e129, 1e130, 1e131, | ||
| 1443 | 1e132, 1e133, 1e134, 1e135, 1e136, 1e137, 1e138, 1e139, 1e140, 1e141, 1e142, | ||
| 1444 | 1e143, 1e144, 1e145, 1e146, 1e147, 1e148, 1e149, 1e150, 1e151, 1e152, 1e153, | ||
| 1445 | 1e154, 1e155, 1e156, 1e157, 1e158, 1e159, 1e160, 1e161, 1e162, 1e163, 1e164, | ||
| 1446 | 1e165, 1e166, 1e167, 1e168, 1e169, 1e170, 1e171, 1e172, 1e173, 1e174, 1e175, | ||
| 1447 | 1e176, 1e177, 1e178, 1e179, 1e180, 1e181, 1e182, 1e183, 1e184, 1e185, 1e186, | ||
| 1448 | 1e187, 1e188, 1e189, 1e190, 1e191, 1e192, 1e193, 1e194, 1e195, 1e196, 1e197, | ||
| 1449 | 1e198, 1e199, 1e200, 1e201, 1e202, 1e203, 1e204, 1e205, 1e206, 1e207, 1e208, | ||
| 1450 | 1e209, 1e210, 1e211, 1e212, 1e213, 1e214, 1e215, 1e216, 1e217, 1e218, 1e219, | ||
| 1451 | 1e220, 1e221, 1e222, 1e223, 1e224, 1e225, 1e226, 1e227, 1e228, 1e229, 1e230, | ||
| 1452 | 1e231, 1e232, 1e233, 1e234, 1e235, 1e236, 1e237, 1e238, 1e239, 1e240, 1e241, | ||
| 1453 | 1e242, 1e243, 1e244, 1e245, 1e246, 1e247, 1e248, 1e249, 1e250, 1e251, 1e252, | ||
| 1454 | 1e253, 1e254, 1e255, 1e256, 1e257, 1e258, 1e259, 1e260, 1e261, 1e262, 1e263, | ||
| 1455 | 1e264, 1e265, 1e266, 1e267, 1e268, 1e269, 1e270, 1e271, 1e272, 1e273, 1e274, | ||
| 1456 | 1e275, 1e276, 1e277, 1e278, 1e279, 1e280, 1e281, 1e282, 1e283, 1e284, 1e285, | ||
| 1457 | 1e286, 1e287, 1e288, 1e289, 1e290, 1e291, 1e292, 1e293, 1e294, 1e295, 1e296, | ||
| 1458 | 1e297, 1e298, 1e299, 1e300, 1e301, 1e302, 1e303, 1e304, 1e305, 1e306, 1e307, | ||
| 1459 | 1e308}; | ||
| 1460 | |||
| 1461 | /* Index extension. */ | ||
| 1462 | const int index_ext_length = 6; | ||
| 1463 | const char *index_ext = ".index"; | ||
| 1464 | const int relay_ext_length = 10; | ||
| 1465 | const char *relay_ext = "-relay-bin"; | ||
| 1466 | /* True if --log-bin option is used. */ | ||
| 1467 | bool log_bin_supplied = false; | ||
| 1468 | |||
| 1469 | time_t server_start_time, flush_status_time; | ||
| 1470 | |||
| 1471 | char server_uuid[UUID_LENGTH + 1]; | ||
| 1472 | const char *server_uuid_ptr; | ||
| 1473 | char mysql_home[FN_REFLEN], pidfile_name[FN_REFLEN]; | ||
| 1474 | char system_time_zone_dst_on[30], system_time_zone_dst_off[30]; | ||
| 1475 | char default_logfile_name[FN_REFLEN]; | ||
| 1476 | char default_binlogfile_name[FN_REFLEN]; | ||
| 1477 | char default_binlog_index_name[FN_REFLEN + index_ext_length]; | ||
| 1478 | char default_relaylogfile_name[FN_REFLEN + relay_ext_length]; | ||
| 1479 | char default_relaylog_index_name[FN_REFLEN + relay_ext_length + | ||
| 1480 | index_ext_length]; | ||
| 1481 | char *default_tz_name; | ||
| 1482 | static char errorlog_filename_buff[FN_REFLEN]; | ||
| 1483 | const char *log_error_dest; | ||
| 1484 | const char *my_share_dir[FN_REFLEN]; | ||
| 1485 | char glob_hostname[HOSTNAME_LENGTH + 1]; | ||
| 1486 | char mysql_real_data_home[FN_REFLEN], lc_messages_dir[FN_REFLEN], | ||
| 1487 | reg_ext[FN_EXTLEN], mysql_charsets_dir[FN_REFLEN], *opt_init_file; | ||
| 1488 | const char *opt_tc_log_file; | ||
| 1489 | char *lc_messages_dir_ptr; | ||
| 1490 | char mysql_unpacked_real_data_home[FN_REFLEN]; | ||
| 1491 | size_t mysql_unpacked_real_data_home_len; | ||
| 1492 | size_t mysql_data_home_len = 1; | ||
| 1493 | uint reg_ext_length; | ||
| 1494 | char logname_path[FN_REFLEN]; | ||
| 1495 | char slow_logname_path[FN_REFLEN]; | ||
| 1496 | char secure_file_real_path[FN_REFLEN]; | ||
| 1497 | char secure_log_real_path[FN_REFLEN]; | ||
| 1498 | Time_zone *default_tz; | ||
| 1499 | char *mysql_data_home = const_cast<char *>("."); | ||
| 1500 | const char *mysql_real_data_home_ptr = mysql_real_data_home; | ||
| 1501 | char *opt_protocol_compression_algorithms; | ||
| 1502 | char server_version[SERVER_VERSION_LENGTH]; | ||
| 1503 | char server_version_suffix[SERVER_VERSION_LENGTH]; | ||
| 1504 | const char *mysqld_unix_port; | ||
| 1505 | char *opt_mysql_tmpdir; | ||
| 1506 | |||
| 1507 | char *opt_authentication_policy; | ||
| 1508 | std::vector<std::string> authentication_policy_list; | ||
| 1509 | /* | ||
| 1510 | keep track of plugin_ref until plugins used in opt_authentication_policy | ||
| 1511 | are properly validated and updated. This will ensure that plugin is not | ||
| 1512 | unloaded in between check() and update() of authentication_policy variable | ||
| 1513 | */ | ||
| 1514 | std::vector<plugin_ref> authentication_policy_plugin_ref; | ||
| 1515 | |||
| 1516 | bool encrypt_tmp_files; | ||
| 1517 | |||
| 1518 | ulonglong tf_sequence_table_max_upper_bound = 0; | ||
| 1519 | |||
| 1520 | /** name of reference on left expression in rewritten IN subquery */ | ||
| 1521 | const char *in_left_expr_name = "<left expr>"; | ||
| 1522 | |||
| 1523 | my_decimal decimal_zero; | ||
| 1524 | /** Number of connection errors from internal server errors. */ | ||
| 1525 | ulong connection_errors_internal = 0; | ||
| 1526 | /** Number of errors when reading the peer address. */ | ||
| 1527 | ulong connection_errors_peer_addr = 0; | ||
| 1528 | |||
| 1529 | /* classes for comparison parsing/processing */ | ||
| 1530 | Eq_creator eq_creator; | ||
| 1531 | Ne_creator ne_creator; | ||
| 1532 | Equal_creator equal_creator; | ||
| 1533 | Gt_creator gt_creator; | ||
| 1534 | Lt_creator lt_creator; | ||
| 1535 | Ge_creator ge_creator; | ||
| 1536 | Le_creator le_creator; | ||
| 1537 | |||
| 1538 | Rpl_global_filter rpl_global_filter; | ||
| 1539 | Rpl_filter *binlog_filter; | ||
| 1540 | Rpl_acf_configuration_handler *rpl_acf_configuration_handler = nullptr; | ||
| 1541 | Source_IO_monitor *rpl_source_io_monitor = nullptr; | ||
| 1542 | Udf_load_service udf_load_service; | ||
| 1543 | |||
| 1544 | struct System_variables global_system_variables; | ||
| 1545 | struct System_variables max_system_variables; | ||
| 1546 | struct System_status_var global_status_var; | ||
| 1547 | |||
| 1548 | MY_TMPDIR mysql_tmpdir_list; | ||
| 1549 | |||
| 1550 | CHARSET_INFO *system_charset_info, *files_charset_info; | ||
| 1551 | CHARSET_INFO *national_charset_info, *table_alias_charset; | ||
| 1552 | CHARSET_INFO *character_set_filesystem; | ||
| 1553 | |||
| 1554 | MY_LOCALE *my_default_lc_messages; | ||
| 1555 | MY_LOCALE *my_default_lc_time_names; | ||
| 1556 | |||
| 1557 | SHOW_COMP_OPTION have_symlink, have_dlopen, have_query_cache; | ||
| 1558 | SHOW_COMP_OPTION have_geometry, have_rtree_keys; | ||
| 1559 | SHOW_COMP_OPTION have_compress; | ||
| 1560 | SHOW_COMP_OPTION have_profiling; | ||
| 1561 | SHOW_COMP_OPTION have_statement_timeout = SHOW_OPTION_DISABLED; | ||
| 1562 | SHOW_COMP_OPTION have_backup_locks; | ||
| 1563 | SHOW_COMP_OPTION have_backup_safe_binlog_info; | ||
| 1564 | SHOW_COMP_OPTION have_snapshot_cloning; | ||
| 1565 | |||
| 1566 | char *enforce_storage_engine = nullptr; | ||
| 1567 | |||
| 1568 | char *utility_user = nullptr; | ||
| 1569 | char *utility_user_password = nullptr; | ||
| 1570 | char *utility_user_schema_access = nullptr; | ||
| 1571 | |||
| 1572 | char *opt_libcoredumper_path = NULL; | ||
| 1573 | /* Plucking this from sql/sql_acl.cc for an array of privilege names */ | ||
| 1574 | extern TYPELIB utility_user_privileges_typelib; | ||
| 1575 | ulonglong utility_user_privileges = 0; | ||
| 1576 | char *utility_user_dynamic_privileges = nullptr; | ||
| 1577 | |||
| 1578 | /* Thread specific variables */ | ||
| 1579 | |||
| 1580 | thread_local MEM_ROOT **THR_MALLOC = nullptr; | ||
| 1581 | |||
| 1582 | mysql_mutex_t LOCK_status, LOCK_uuid_generator, LOCK_crypt, | ||
| 1583 | LOCK_global_system_variables, LOCK_user_conn, LOCK_error_messages; | ||
| 1584 | mysql_mutex_t LOCK_sql_rand; | ||
| 1585 | |||
| 1586 | mysql_mutex_t LOCK_global_user_client_stats, LOCK_global_table_stats, | ||
| 1587 | LOCK_global_index_stats; | ||
| 1588 | /** | ||
| 1589 | The below lock protects access to two global server variables: | ||
| 1590 | max_prepared_stmt_count and prepared_stmt_count. These variables | ||
| 1591 | set the limit and hold the current total number of prepared statements | ||
| 1592 | in the server, respectively. As PREPARE/DEALLOCATE rate in a loaded | ||
| 1593 | server may be fairly high, we need a dedicated lock. | ||
| 1594 | */ | ||
| 1595 | mysql_mutex_t LOCK_prepared_stmt_count; | ||
| 1596 | |||
| 1597 | /** | ||
| 1598 | Protects slave_list in rpl_source.cc; the list of currently running | ||
| 1599 | dump threads with metadata for the replica. | ||
| 1600 | */ | ||
| 1601 | mysql_mutex_t LOCK_replica_list; | ||
| 1602 | /* | ||
| 1603 | The below two locks are introduced as guards (second mutex) for | ||
| 1604 | the global variables sql_replica_skip_counter and replica_net_timeout | ||
| 1605 | respectively. See fix_slave_skip_counter/fix_replica_net_timeout | ||
| 1606 | for more details | ||
| 1607 | */ | ||
| 1608 | mysql_mutex_t LOCK_sql_replica_skip_counter; | ||
| 1609 | mysql_mutex_t LOCK_replica_net_timeout; | ||
| 1610 | mysql_mutex_t LOCK_replica_trans_dep_tracker; | ||
| 1611 | mysql_mutex_t LOCK_log_throttle_qni; | ||
| 1612 | mysql_rwlock_t LOCK_sys_init_connect, LOCK_sys_init_replica; | ||
| 1613 | mysql_rwlock_t LOCK_system_variables_hash; | ||
| 1614 | my_thread_handle signal_thread_id; | ||
| 1615 | sigset_t mysqld_signal_mask; | ||
| 1616 | my_thread_attr_t connection_attrib; | ||
| 1617 | mysql_mutex_t LOCK_server_started; | ||
| 1618 | mysql_cond_t COND_server_started; | ||
| 1619 | mysql_mutex_t LOCK_reset_gtid_table; | ||
| 1620 | mysql_mutex_t LOCK_compress_gtid_table; | ||
| 1621 | mysql_cond_t COND_compress_gtid_table; | ||
| 1622 | mysql_mutex_t LOCK_collect_instance_log; | ||
| 1623 | #if !defined(_WIN32) | ||
| 1624 | mysql_mutex_t LOCK_socket_listener_active; | ||
| 1625 | mysql_cond_t COND_socket_listener_active; | ||
| 1626 | mysql_mutex_t LOCK_start_signal_handler; | ||
| 1627 | mysql_cond_t COND_start_signal_handler; | ||
| 1628 | #endif | ||
| 1629 | mysql_rwlock_t LOCK_consistent_snapshot; | ||
| 1630 | |||
| 1631 | /* | ||
| 1632 | The below lock protects access to global server variable | ||
| 1633 | keyring_operations. | ||
| 1634 | */ | ||
| 1635 | mysql_mutex_t LOCK_keyring_operations; | ||
| 1636 | /* | ||
| 1637 | The below lock protects to execute commands 'ALTER INSTANCE ROTATE BINLOG | ||
| 1638 | MASTER KEY' and 'SET @@GLOBAL.binlog_encryption=ON/OFF' in parallel. | ||
| 1639 | */ | ||
| 1640 | mysql_mutex_t LOCK_rotate_binlog_master_key; | ||
| 1641 | |||
| 1642 | /* | ||
| 1643 | The below lock protects to execute commands 'CREATE/ALTER USER' and | ||
| 1644 | 'SET @@GLOBAL.authentication_policy...' in parallel. | ||
| 1645 | */ | ||
| 1646 | mysql_mutex_t LOCK_authentication_policy; | ||
| 1647 | |||
| 1648 | mysql_mutex_t LOCK_global_conn_mem_limit; | ||
| 1649 | |||
| 1650 | bool mysqld_server_started = false; | ||
| 1651 | /** | ||
| 1652 | Set to true to signal at startup if the process must die. | ||
| 1653 | |||
| 1654 | Needed because kill_mysql() will not do anything before | ||
| 1655 | the server is fully initialized. Thus it now just sets this | ||
| 1656 | flag to on and exits. And then mysqld_main() will check if | ||
| 1657 | the flag is on at the right place and exit the process if it | ||
| 1658 | is. | ||
| 1659 | */ | ||
| 1660 | static bool mysqld_process_must_end_at_startup = false; | ||
| 1661 | |||
| 1662 | /* replication parameters, if master_host is not NULL, we are a slave */ | ||
| 1663 | uint report_port = 0; | ||
| 1664 | ulong master_retry_count = 0; | ||
| 1665 | const char *master_info_file; | ||
| 1666 | const char *relay_log_info_file; | ||
| 1667 | char *report_user, *report_password, *report_host; | ||
| 1668 | char *opt_relay_logname = nullptr, *opt_relaylog_index_name = nullptr; | ||
| 1669 | /* | ||
| 1670 | True if the --relay-log-index is set by users from | ||
| 1671 | config file or command line. | ||
| 1672 | */ | ||
| 1673 | bool opt_relaylog_index_name_supplied = false; | ||
| 1674 | /* | ||
| 1675 | True if the --relay-log is set by users from | ||
| 1676 | config file or command line. | ||
| 1677 | */ | ||
| 1678 | bool opt_relay_logname_supplied = false; | ||
| 1679 | /* | ||
| 1680 | True if --log-replica-updates option is set explicitly | ||
| 1681 | on command line or configuration file. | ||
| 1682 | */ | ||
| 1683 | bool log_replica_updates_supplied = false; | ||
| 1684 | |||
| 1685 | /* | ||
| 1686 | True if --replica-preserve-commit-order-supplied option is set explicitly | ||
| 1687 | on command line or configuration file. | ||
| 1688 | */ | ||
| 1689 | bool replica_preserve_commit_order_supplied = false; | ||
| 1690 | char *opt_general_logname, *opt_slow_logname, *opt_bin_logname; | ||
| 1691 | |||
| 1692 | /* | ||
| 1693 | True if expire_logs_days and binlog_expire_logs_seconds are set | ||
| 1694 | explicitly. | ||
| 1695 | */ | ||
| 1696 | bool expire_logs_days_supplied = false; | ||
| 1697 | bool binlog_expire_logs_seconds_supplied = false; | ||
| 1698 | /* Static variables */ | ||
| 1699 | |||
| 1700 | static bool opt_myisam_log; | ||
| 1701 | static int cleanup_done; | ||
| 1702 | static ulong opt_specialflag; | ||
| 1703 | char *opt_binlog_index_name; | ||
| 1704 | char *mysql_home_ptr, *pidfile_name_ptr; | ||
| 1705 | char *default_auth_plugin; | ||
| 1706 | /** | ||
| 1707 | Memory for allocating command line arguments, after load_defaults(). | ||
| 1708 | */ | ||
| 1709 | static MEM_ROOT argv_alloc{PSI_NOT_INSTRUMENTED, 512}; | ||
| 1710 | /** Remaining command line arguments (count), filtered by handle_options().*/ | ||
| 1711 | static int remaining_argc; | ||
| 1712 | /** Remaining command line arguments (arguments), filtered by | ||
| 1713 | * handle_options().*/ | ||
| 1714 | static char **remaining_argv; | ||
| 1715 | |||
| 1716 | /** | ||
| 1717 | Holds the "original" (i.e. as on startup) set of arguments. | ||
| 1718 | |||
| 1719 | The argument processing goes as follows: | ||
| 1720 | 1. At startup the "original" set of arguments is shallow-copied into | ||
| 1721 | the read only list @ref orig_argv. | ||
| 1722 | 2. The config file arguments are read from the config files (.cnf and | ||
| 1723 | persisted read-only) and are appended as command line arguments. | ||
| 1724 | In the process the argv is deep copied because of the expansion | ||
| 1725 | 3. The result from 2 is set into @ref remaining_argv / @ref remaining_argc. | ||
| 1726 | 4. Then remaining_argv is fed into various consumers: | ||
| 1727 | - the server compiled in set of arguments | ||
| 1728 | - the early plugins | ||
| 1729 | - the rest of the plugins | ||
| 1730 | - the error log | ||
| 1731 | - the components from the persisted dynamic loader init. | ||
| 1732 | All of the above "take away" the values they match from the extended | ||
| 1733 | command line set. And vary the values of @ref my_getopt_skip_unknown | ||
| 1734 | according to their needs (mostly keep it set). | ||
| 1735 | As a result, when the server is done booting up the things that remain | ||
| 1736 | in remaining_argv become less and less. | ||
| 1737 | 5. When the bootstrap process is done a check is run: | ||
| 1738 | my_getopt_skip_unknown is set to off and the argument parser is called | ||
| 1739 | on remaining_argv with an empty set of argument definitions. | ||
| 1740 | This ensures that all of the remaining argument values in remaining_argv | ||
| 1741 | are either marked as "loose" (i.e. optional) or are "consumed" by prior | ||
| 1742 | argument list processings. | ||
| 1743 | The side effect of this is that all --loose arguments are also consumed | ||
| 1744 | out of remaining_argv. | ||
| 1745 | 6. A check is made if the remaining_argv is an empty list. If not the server | ||
| 1746 | exits. | ||
| 1747 | 7. At this point the server is marked as successfully started. | ||
| 1748 | 8. Subsequent argument processings happen when e.g. a plugin is loaded via | ||
| 1749 | @ref mysql_install_plugin or a component registers system variables via | ||
| 1750 | @ref mysql_component_sys_variable_imp::register_variable. However, since | ||
| 1751 | remaining_argv is empty these need to run over the orig_argc/orig_argv. | ||
| 1752 | But argument value assignment would normally "eat" out the values found. | ||
| 1753 | This would mean that the orig_argv array will get shortened and if you | ||
| 1754 | load the same plugin twice for example its system variables will not have | ||
| 1755 | the values supplied the second time they start. | ||
| 1756 | Thus once the server is started (@ref mysqld_server_started is on) any | ||
| 1757 | argument value parsing should happen over a *copy* of orig_argc/orig_argv | ||
| 1758 | that should subsequently be discarded. | ||
| 1759 | @ref remaining_argv should not be consulted anymore at this point. | ||
| 1760 | */ | ||
| 1761 | int orig_argc; | ||
| 1762 | char **orig_argv; | ||
| 1763 | namespace { | ||
| 1764 | FILE *nstdout = nullptr; | ||
| 1765 | char my_progpath[FN_REFLEN]; | ||
| 1766 | const char *my_orig_progname = nullptr; | ||
| 1767 | |||
| 1768 | /** | ||
| 1769 | This variable holds the exit value of the signal handler thread. | ||
| 1770 | */ | ||
| 1771 | std::atomic<int> signal_hand_thr_exit_code(MYSQLD_SUCCESS_EXIT); | ||
| 1772 | |||
| 1773 | /** | ||
| 1774 | Inspects the program name in argv[0] and substitutes the full path | ||
| 1775 | of the executable. | ||
| 1776 | |||
| 1777 | @param argv argument vector (array) for executable. | ||
| 1778 | */ | ||
| 1779 | 12121 | void substitute_progpath(char **argv) { | |
| 1780 |
2/2✓ Branch 0 taken 12119 times.
✓ Branch 1 taken 2 times.
|
12121 | if (test_if_hard_path(argv[0])) return; |
| 1781 | |||
| 1782 | #if defined(_WIN32) | ||
| 1783 | if (GetModuleFileName(NULL, my_progpath, sizeof(my_progpath))) { | ||
| 1784 | my_orig_progname = argv[0]; | ||
| 1785 | argv[0] = my_progpath; | ||
| 1786 | } | ||
| 1787 | #else | ||
| 1788 | /* If the path has a directory component, use my_realpath() | ||
| 1789 | (implicitly relative to cwd) */ | ||
| 1790 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 1 times.
|
3 | if (strchr(argv[0], FN_LIBCHAR) != nullptr && |
| 1791 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | !my_realpath(my_progpath, argv[0], MYF(0))) { |
| 1792 | 1 | my_orig_progname = argv[0]; | |
| 1793 | 1 | argv[0] = my_progpath; | |
| 1794 | 1 | return; | |
| 1795 | } | ||
| 1796 | |||
| 1797 | // my_realpath() cannot resolve it, it must be a bare executable | ||
| 1798 | // name in path | ||
| 1799 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(strchr(argv[0], FN_LIBCHAR) == nullptr); |
| 1800 | |||
| 1801 | 1 | const char *spbegin = getenv("PATH"); | |
| 1802 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (spbegin == nullptr) spbegin = ""; |
| 1803 | 1 | const char *spend = spbegin + strlen(spbegin); | |
| 1804 | |||
| 1805 | while (true) { | ||
| 1806 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | const char *colonend = std::find(spbegin, spend, ':'); |
| 1807 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | std::string cand{spbegin, colonend}; |
| 1808 | 1 | spbegin = colonend + 1; | |
| 1809 | |||
| 1810 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | cand.append(1, '/'); |
| 1811 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | cand.append(argv[0]); |
| 1812 | |||
| 1813 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (my_access(cand.c_str(), X_OK) == 0) { |
| 1814 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | if (my_realpath(my_progpath, cand.c_str(), MYF(0))) { |
| 1815 | // Fallback to raw cand | ||
| 1816 | ✗ | assert(cand.length() < FN_REFLEN); | |
| 1817 | ✗ | std::copy(cand.begin(), cand.end(), my_progpath); | |
| 1818 | ✗ | my_progpath[cand.length()] = '\0'; | |
| 1819 | } | ||
| 1820 | 1 | my_orig_progname = argv[0]; | |
| 1821 | 1 | argv[0] = my_progpath; | |
| 1822 | 1 | break; | |
| 1823 | } | ||
| 1824 | ✗ | if (colonend == spend) { | |
| 1825 | ✗ | assert(false); | |
| 1826 | break; | ||
| 1827 | } | ||
| 1828 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | } // while (true) |
| 1829 | #endif // defined(_WIN32) | ||
| 1830 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (my_orig_progname == nullptr) { |
| 1831 | ✗ | LogErr(WARNING_LEVEL, ER_FAILED_TO_GET_ABSOLUTE_PATH, argv[0]); | |
| 1832 | } | ||
| 1833 | } | ||
| 1834 | } // namespace | ||
| 1835 | |||
| 1836 | static Connection_acceptor<Mysqld_socket_listener> *mysqld_socket_acceptor = | ||
| 1837 | nullptr; | ||
| 1838 | #ifdef _WIN32 | ||
| 1839 | static Named_pipe_listener *named_pipe_listener = NULL; | ||
| 1840 | Connection_acceptor<Named_pipe_listener> *named_pipe_acceptor = NULL; | ||
| 1841 | Connection_acceptor<Shared_mem_listener> *shared_mem_acceptor = NULL; | ||
| 1842 | mysql_rwlock_t LOCK_named_pipe_full_access_group; | ||
| 1843 | char *named_pipe_full_access_group; | ||
| 1844 | #endif | ||
| 1845 | |||
| 1846 | Checkable_rwlock *global_sid_lock = nullptr; | ||
| 1847 | Sid_map *global_sid_map = nullptr; | ||
| 1848 | Gtid_state *gtid_state = nullptr; | ||
| 1849 | Gtid_table_persistor *gtid_table_persistor = nullptr; | ||
| 1850 | |||
| 1851 | /* cache for persisted variables */ | ||
| 1852 | static Persisted_variables_cache persisted_variables_cache; | ||
| 1853 | |||
| 1854 | 12 | void persisted_variables_refresh_keyring_support() { | |
| 1855 | 12 | persisted_variables_cache.keyring_support_available(); | |
| 1856 | 12 | } | |
| 1857 | |||
| 1858 | 33 | void set_remaining_args(int argc, char **argv) { | |
| 1859 | 33 | remaining_argc = argc; | |
| 1860 | 33 | remaining_argv = argv; | |
| 1861 | 33 | } | |
| 1862 | |||
| 1863 | 127 | int *get_remaining_argc() { return &remaining_argc; } | |
| 1864 | |||
| 1865 | 127 | char ***get_remaining_argv() { return &remaining_argv; } | |
| 1866 | |||
| 1867 | /* | ||
| 1868 | Multiple threads of execution use the random state maintained in global | ||
| 1869 | sql_rand to generate random numbers. sql_rnd_with_mutex use mutex | ||
| 1870 | LOCK_sql_rand to protect sql_rand across multiple instantiations that use | ||
| 1871 | sql_rand to generate random numbers. | ||
| 1872 | */ | ||
| 1873 | 1358842 | ulong sql_rnd_with_mutex() { | |
| 1874 | 1358842 | mysql_mutex_lock(&LOCK_sql_rand); | |
| 1875 | ulong tmp = | ||
| 1876 | 1359202 | (ulong)(my_rnd(&sql_rand) * 0xffffffff); /* make all bits random */ | |
| 1877 | 1359202 | mysql_mutex_unlock(&LOCK_sql_rand); | |
| 1878 | 1359202 | return tmp; | |
| 1879 | } | ||
| 1880 | |||
| 1881 | 360793 | struct System_status_var *get_thd_status_var(THD *thd, bool *aggregated) { | |
| 1882 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 360793 times.
|
360793 | assert(thd != nullptr); |
| 1883 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 360793 times.
|
360793 | assert(aggregated != nullptr); |
| 1884 | 360793 | *aggregated = thd->status_var_aggregated; | |
| 1885 | 360793 | return &thd->status_var; | |
| 1886 | } | ||
| 1887 | |||
| 1888 | #ifndef NDEBUG | ||
| 1889 | 18932808 | bool thd_mem_cnt_alloc(THD *thd, size_t size, const char *key_name) { | |
| 1890 | 18932808 | thd->current_key_name = key_name; | |
| 1891 | 18932808 | return thd->m_mem_cnt.alloc_cnt(size); | |
| 1892 | } | ||
| 1893 | #else | ||
| 1894 | bool thd_mem_cnt_alloc(THD *thd, size_t size) { | ||
| 1895 | return thd->m_mem_cnt.alloc_cnt(size); | ||
| 1896 | } | ||
| 1897 | #endif | ||
| 1898 | |||
| 1899 | 18079630 | void thd_mem_cnt_free(THD *thd, size_t size) { thd->m_mem_cnt.free_cnt(size); } | |
| 1900 | |||
| 1901 | 12110 | static void option_error_reporter(enum loglevel level, uint ecode, ...) { | |
| 1902 | va_list args; | ||
| 1903 | 12110 | va_start(args, ecode); | |
| 1904 | |||
| 1905 | /* | ||
| 1906 | Don't print warnings for --loose options during initialize. | ||
| 1907 | */ | ||
| 1908 |
5/6✓ Branch 0 taken 12075 times.
✓ Branch 1 taken 35 times.
✓ Branch 2 taken 139 times.
✓ Branch 3 taken 11936 times.
✓ Branch 4 taken 139 times.
✗ Branch 5 not taken.
|
12110 | if (level == ERROR_LEVEL || !opt_initialize || (log_error_verbosity > 1)) { |
| 1909 |
1/2✓ Branch 0 taken 12110 times.
✗ Branch 1 not taken.
|
12110 | error_log_print(level, ecode, args); |
| 1910 | } | ||
| 1911 | 12110 | va_end(args); | |
| 1912 | 12110 | } | |
| 1913 | |||
| 1914 | /** | ||
| 1915 | Character set and collation error reporter that prints to sql error log. | ||
| 1916 | @param level log message level | ||
| 1917 | @param ecode Error code of the error message. | ||
| 1918 | |||
| 1919 | This routine is used to print character set and collation | ||
| 1920 | warnings and errors inside an already running mysqld server, | ||
| 1921 | e.g. when a character set or collation is requested for the very first time | ||
| 1922 | and its initialization does not go well for some reasons. | ||
| 1923 | */ | ||
| 1924 | |||
| 1925 | 5 | static void charset_error_reporter(enum loglevel level, uint ecode, ...) { | |
| 1926 | va_list args; | ||
| 1927 | 5 | va_start(args, ecode); | |
| 1928 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | error_log_print(level, ecode, args); |
| 1929 | 5 | va_end(args); | |
| 1930 | 5 | } | |
| 1931 | |||
| 1932 | struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD() | ||
| 1933 | |||
| 1934 | #ifndef _WIN32 | ||
| 1935 | PasswdValue user_info; | ||
| 1936 | static my_thread_t main_thread_id; | ||
| 1937 | #endif // !_WIN32 | ||
| 1938 | |||
| 1939 | /* OS specific variables */ | ||
| 1940 | |||
| 1941 | #ifdef _WIN32 | ||
| 1942 | static bool mysqld_early_option = false; | ||
| 1943 | static bool windows_service = false; | ||
| 1944 | static bool use_opt_args; | ||
| 1945 | static int opt_argc; | ||
| 1946 | static char **opt_argv; | ||
| 1947 | static char **my_global_argv = nullptr; | ||
| 1948 | static int my_global_argc; | ||
| 1949 | |||
| 1950 | static mysql_mutex_t LOCK_handler_count; | ||
| 1951 | static mysql_cond_t COND_handler_count; | ||
| 1952 | static HANDLE hEventShutdown; | ||
| 1953 | static HANDLE hEventRestart; | ||
| 1954 | const char *shared_memory_base_name = default_shared_memory_base_name; | ||
| 1955 | bool opt_enable_shared_memory; | ||
| 1956 | static char shutdown_event_name[40]; | ||
| 1957 | static char restart_event_name[40]; | ||
| 1958 | static NTService Service; ///< Service object for WinNT | ||
| 1959 | #endif /* _WIN32 */ | ||
| 1960 | |||
| 1961 | /** | ||
| 1962 | Flag indicating if dynamic plugins have been loaded. Only to be accessed | ||
| 1963 | by main thread. | ||
| 1964 | */ | ||
| 1965 | bool dynamic_plugins_are_initialized = false; | ||
| 1966 | |||
| 1967 | #ifndef NDEBUG | ||
| 1968 | static const char *default_dbug_option; | ||
| 1969 | #endif | ||
| 1970 | |||
| 1971 | bool opt_use_ssl = true; | ||
| 1972 | bool opt_use_admin_ssl = true; | ||
| 1973 | ulong opt_ssl_fips_mode = SSL_FIPS_MODE_OFF; | ||
| 1974 | |||
| 1975 | /* Function declarations */ | ||
| 1976 | |||
| 1977 | static int mysql_init_variables(); | ||
| 1978 | static int get_options(int *argc_ptr, char ***argv_ptr); | ||
| 1979 | static void add_terminator(vector<my_option> *options); | ||
| 1980 | extern "C" bool mysqld_get_one_option(int, const struct my_option *, char *); | ||
| 1981 | static void set_server_version(void); | ||
| 1982 | static int init_thread_environment(); | ||
| 1983 | static const char *get_relative_path(const char *path); | ||
| 1984 | static int fix_paths(void); | ||
| 1985 | static int test_if_case_insensitive(const char *dir_name); | ||
| 1986 | static void end_ssl(); | ||
| 1987 | static void delete_dictionary_tablespace(); | ||
| 1988 | |||
| 1989 | extern "C" void *signal_hand(void *arg); | ||
| 1990 | static bool pid_file_created = false; | ||
| 1991 | static void usage(void); | ||
| 1992 | static void clean_up_mutexes(void); | ||
| 1993 | static bool create_pid_file(); | ||
| 1994 | [[noreturn]] static void mysqld_exit(int exit_code); | ||
| 1995 | static void delete_pid_file(myf flags); | ||
| 1996 | static void clean_up(bool print_message); | ||
| 1997 | static int handle_early_options(); | ||
| 1998 | static void adjust_related_options(ulong *requested_open_files); | ||
| 1999 | static void process_bootstrap(); | ||
| 2000 | #ifdef HAVE_PSI_INTERFACE | ||
| 2001 | static void init_server_psi_keys(); | ||
| 2002 | #endif | ||
| 2003 | |||
| 2004 | /** | ||
| 2005 | Notify any waiters that the server components have been initialized. | ||
| 2006 | Used by the signal handler thread and by Cluster. | ||
| 2007 | |||
| 2008 | @see signal_hand | ||
| 2009 | */ | ||
| 2010 | |||
| 2011 | 11977 | static void server_components_initialized() { | |
| 2012 | 11977 | mysql_mutex_lock(&LOCK_server_started); | |
| 2013 | 11977 | mysqld_server_started = true; | |
| 2014 | 11977 | mysql_cond_broadcast(&COND_server_started); | |
| 2015 | 11977 | mysql_mutex_unlock(&LOCK_server_started); | |
| 2016 | 11977 | } | |
| 2017 | |||
| 2018 | SERVICE_TYPE(mysql_runtime_error) * error_service; | ||
| 2019 | SERVICE_TYPE(mysql_psi_system_v1) * system_service; | ||
| 2020 | SERVICE_TYPE(mysql_rwlock_v1) * rwlock_service; | ||
| 2021 | SERVICE_TYPE_NO_CONST(registry) * srv_registry; | ||
| 2022 | SERVICE_TYPE(dynamic_loader_scheme_file) * scheme_file_srv; | ||
| 2023 | using loader_type_t = SERVICE_TYPE_NO_CONST(dynamic_loader); | ||
| 2024 | using runtime_error_type_t = SERVICE_TYPE_NO_CONST(mysql_runtime_error); | ||
| 2025 | using psi_system_type_t = SERVICE_TYPE_NO_CONST(mysql_psi_system_v1); | ||
| 2026 | using rwlock_type_t = SERVICE_TYPE_NO_CONST(mysql_rwlock_v1); | ||
| 2027 | using loader_scheme_type_t = SERVICE_TYPE_NO_CONST(dynamic_loader_scheme_file); | ||
| 2028 | extern REQUIRES_SERVICE_PLACEHOLDER(mysql_rwlock_v1); | ||
| 2029 | extern REQUIRES_SERVICE_PLACEHOLDER(mysql_psi_system_v1); | ||
| 2030 | extern bool initialize_minimal_chassis(SERVICE_TYPE_NO_CONST(registry) * | ||
| 2031 | *registry); | ||
| 2032 | extern bool deinitialize_minimal_chassis(SERVICE_TYPE_NO_CONST(registry) * | ||
| 2033 | registry); | ||
| 2034 | /* | ||
| 2035 | List of components to be loaded directly using dynamic loader load. | ||
| 2036 | These components should to be present in the plugin directory path. | ||
| 2037 | */ | ||
| 2038 | const char *component_urns[] = {"file://component_reference_cache"}; | ||
| 2039 | #define NUMBER_OF_COMPONENTS 1 | ||
| 2040 | |||
| 2041 | /** | ||
| 2042 | Initializes component infrastructure by bootstrapping core component | ||
| 2043 | subsystem. | ||
| 2044 | |||
| 2045 | @return Status of performed operation | ||
| 2046 | @retval false success | ||
| 2047 | @retval true failure | ||
| 2048 | */ | ||
| 2049 | 12109 | static bool component_infrastructure_init() { | |
| 2050 | 12109 | bool retval = false; | |
| 2051 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | if (initialize_minimal_chassis(&srv_registry)) { |
| 2052 | ✗ | LogErr(ERROR_LEVEL, ER_COMPONENTS_INFRASTRUCTURE_BOOTSTRAP); | |
| 2053 | ✗ | return true; | |
| 2054 | } | ||
| 2055 | /* Here minimal_chassis dynamic_loader_scheme_file service has | ||
| 2056 | to be acquired */ | ||
| 2057 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | srv_registry->acquire( |
| 2058 | "dynamic_loader_scheme_file.mysql_minimal_chassis", | ||
| 2059 | reinterpret_cast<my_h_service *>( | ||
| 2060 | const_cast<loader_scheme_type_t **>(&scheme_file_srv))); | ||
| 2061 | |||
| 2062 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | srv_registry->acquire("dynamic_loader", |
| 2063 | reinterpret_cast<my_h_service *>( | ||
| 2064 | const_cast<loader_type_t **>(&dynamic_loader_srv))); | ||
| 2065 | |||
| 2066 | my_service<SERVICE_TYPE(registry_registration)> registrator( | ||
| 2067 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | "registry_registration", srv_registry); |
| 2068 | |||
| 2069 | // Sets default file scheme loader for MySQL server. | ||
| 2070 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
12109 | registrator->set_default( |
| 2071 | "dynamic_loader_scheme_file.mysql_server_path_filter"); | ||
| 2072 | |||
| 2073 | // Sets default rw_lock for MySQL server. | ||
| 2074 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
12109 | registrator->set_default("mysql_rwlock_v1.mysql_server"); |
| 2075 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | srv_registry->acquire("mysql_rwlock_v1.mysql_server", |
| 2076 | reinterpret_cast<my_h_service *>( | ||
| 2077 | const_cast<rwlock_type_t **>(&rwlock_service))); | ||
| 2078 | 12109 | mysql_service_mysql_rwlock_v1 = | |
| 2079 | reinterpret_cast<SERVICE_TYPE(mysql_rwlock_v1) *>(rwlock_service); | ||
| 2080 | |||
| 2081 | // Sets default psi_system event service for MySQL server. | ||
| 2082 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
12109 | registrator->set_default("mysql_psi_system_v1.mysql_server"); |
| 2083 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | srv_registry->acquire("mysql_psi_system_v1.mysql_server", |
| 2084 | reinterpret_cast<my_h_service *>( | ||
| 2085 | const_cast<psi_system_type_t **>(&system_service))); | ||
| 2086 | /* This service variable is needed for mysql_unload_plugin */ | ||
| 2087 | 12109 | mysql_service_mysql_psi_system_v1 = | |
| 2088 | reinterpret_cast<SERVICE_TYPE(mysql_psi_system_v1) *>(system_service); | ||
| 2089 | |||
| 2090 | // Sets default mysql_runtime_error for MySQL server. | ||
| 2091 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
12109 | registrator->set_default("mysql_runtime_error.mysql_server"); |
| 2092 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | srv_registry->acquire( |
| 2093 | "mysql_runtime_error.mysql_server", | ||
| 2094 | reinterpret_cast<my_h_service *>( | ||
| 2095 | const_cast<runtime_error_type_t **>(&error_service))); | ||
| 2096 | /* This service variable is needed where ever mysql_error_service_printf() | ||
| 2097 | service api is used */ | ||
| 2098 | 12109 | mysql_service_mysql_runtime_error = | |
| 2099 | reinterpret_cast<SERVICE_TYPE(mysql_runtime_error) *>(error_service); | ||
| 2100 | |||
| 2101 | 12109 | return retval; | |
| 2102 | 12109 | } | |
| 2103 | |||
| 2104 | /** | ||
| 2105 | This function is used to initialize the mysql_server component services. | ||
| 2106 | */ | ||
| 2107 | 11443 | static void server_component_init() { mysql_comp_sys_var_services_init(); } | |
| 2108 | |||
| 2109 | /** | ||
| 2110 | Initializes MySQL Server component infrastructure part by initialize of | ||
| 2111 | dynamic loader persistence. | ||
| 2112 | |||
| 2113 | @return Status of performed operation | ||
| 2114 | @retval false success | ||
| 2115 | @retval true failure | ||
| 2116 | */ | ||
| 2117 | |||
| 2118 | 11443 | static bool mysql_component_infrastructure_init() { | |
| 2119 | /* We need a temporary THD during boot */ | ||
| 2120 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | Auto_THD thd; |
| 2121 | 11443 | Disable_autocommit_guard autocommit_guard(thd.thd); | |
| 2122 | dd::cache::Dictionary_client::Auto_releaser scope_releaser( | ||
| 2123 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | thd.thd->dd_client()); |
| 2124 |
2/4✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11443 times.
|
11443 | if (persistent_dynamic_loader_init(thd.thd)) { |
| 2125 | ✗ | LogErr(ERROR_LEVEL, ER_COMPONENTS_PERSIST_LOADER_BOOTSTRAP); | |
| 2126 | ✗ | trans_rollback_stmt(thd.thd); | |
| 2127 | // Full rollback in case we have THD::transaction_rollback_request. | ||
| 2128 | ✗ | trans_rollback(thd.thd); | |
| 2129 | ✗ | return true; | |
| 2130 | } | ||
| 2131 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | server_component_init(); |
| 2132 |
4/8✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11443 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11443 times.
|
11443 | return trans_commit_stmt(thd.thd) || trans_commit(thd.thd); |
| 2133 | 11443 | } | |
| 2134 | |||
| 2135 | /** | ||
| 2136 | De-initializes Component infrastructure by de-initialization of the MySQL | ||
| 2137 | Server services (persistent dynamic loader) followed by de-initailization of | ||
| 2138 | the core Components infrostructure. | ||
| 2139 | |||
| 2140 | @return Status of performed operation | ||
| 2141 | @retval false success | ||
| 2142 | @retval true failure | ||
| 2143 | */ | ||
| 2144 | 10491 | static bool component_infrastructure_deinit() { | |
| 2145 | 10491 | persistent_dynamic_loader_deinit(); | |
| 2146 | 10491 | bool retval = false; | |
| 2147 | |||
| 2148 | 10491 | srv_registry->release(reinterpret_cast<my_h_service>( | |
| 2149 | const_cast<loader_scheme_type_t *>(scheme_file_srv))); | ||
| 2150 | 10491 | srv_registry->release(reinterpret_cast<my_h_service>( | |
| 2151 | const_cast<loader_type_t *>(dynamic_loader_srv))); | ||
| 2152 | 10491 | srv_registry->release(reinterpret_cast<my_h_service>( | |
| 2153 | const_cast<runtime_error_type_t *>(error_service))); | ||
| 2154 | 10491 | srv_registry->release(reinterpret_cast<my_h_service>( | |
| 2155 | const_cast<psi_system_type_t *>(system_service))); | ||
| 2156 | 10491 | srv_registry->release(reinterpret_cast<my_h_service>( | |
| 2157 | const_cast<rwlock_type_t *>(rwlock_service))); | ||
| 2158 | |||
| 2159 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10491 times.
|
10491 | if (deinitialize_minimal_chassis(srv_registry)) { |
| 2160 | ✗ | LogErr(ERROR_LEVEL, ER_COMPONENTS_INFRASTRUCTURE_SHUTDOWN); | |
| 2161 | ✗ | retval = true; | |
| 2162 | } | ||
| 2163 | 10491 | return retval; | |
| 2164 | } | ||
| 2165 | |||
| 2166 | 12109 | static bool initialize_manifest_file_components() { | |
| 2167 | /* | ||
| 2168 | Read components from manifest file | ||
| 2169 | |||
| 2170 | Note that the word 'components' is used differently in the server. | ||
| 2171 | Here we address the component service infrastructure, but in other places, | ||
| 2172 | like init_server_components() the word is used in bit different context | ||
| 2173 | and may mean general idea of modularity. | ||
| 2174 | */ | ||
| 2175 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | assert(strlen(mysql_real_data_home) > 0); |
| 2176 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
24218 | g_deployed_components = |
| 2177 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
|
12109 | new (std::nothrow) Deployed_components(my_progname, mysql_real_data_home); |
| 2178 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
24218 | if (g_deployed_components == nullptr || |
| 2179 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | g_deployed_components->valid() == false) { |
| 2180 | /*Error would have been raised by Deployed_components constructor */ | ||
| 2181 | ✗ | g_deployed_components = nullptr; | |
| 2182 | ✗ | return true; | |
| 2183 | } | ||
| 2184 | 12109 | return false; | |
| 2185 | } | ||
| 2186 | |||
| 2187 | 10491 | static void deinitialize_manifest_file_components() { | |
| 2188 |
1/2✓ Branch 0 taken 10491 times.
✗ Branch 1 not taken.
|
10491 | if (g_deployed_components != nullptr) { |
| 2189 | /* Error if any would have been raised */ | ||
| 2190 |
1/2✓ Branch 0 taken 10491 times.
✗ Branch 1 not taken.
|
10491 | delete g_deployed_components; |
| 2191 | 10491 | g_deployed_components = nullptr; | |
| 2192 | } | ||
| 2193 | 10491 | } | |
| 2194 | |||
| 2195 | /** | ||
| 2196 | Block and wait until server components have been initialized. | ||
| 2197 | */ | ||
| 2198 | |||
| 2199 | 11691 | static void server_components_init_wait() { | |
| 2200 | 11691 | mysql_mutex_lock(&LOCK_server_started); | |
| 2201 |
2/2✓ Branch 0 taken 9749 times.
✓ Branch 1 taken 11691 times.
|
21440 | while (!mysqld_server_started) |
| 2202 | 9749 | mysql_cond_wait(&COND_server_started, &LOCK_server_started); | |
| 2203 | 11691 | mysql_mutex_unlock(&LOCK_server_started); | |
| 2204 | 11691 | } | |
| 2205 | |||
| 2206 | /**************************************************************************** | ||
| 2207 | ** Code to end mysqld | ||
| 2208 | ****************************************************************************/ | ||
| 2209 | |||
| 2210 | /** | ||
| 2211 | This class implements callback function used by close_connections() | ||
| 2212 | to set KILL_CONNECTION flag on all thds in thd list. | ||
| 2213 | If m_kill_dump_thread_flag is not set it kills all other threads | ||
| 2214 | except dump threads. If this flag is set, it kills dump threads. | ||
| 2215 | */ | ||
| 2216 | class Set_kill_conn : public Do_THD_Impl { | ||
| 2217 | private: | ||
| 2218 | int m_dump_thread_count; | ||
| 2219 | bool m_kill_dump_threads_flag; | ||
| 2220 | |||
| 2221 | public: | ||
| 2222 | 10103 | Set_kill_conn() : m_dump_thread_count(0), m_kill_dump_threads_flag(false) {} | |
| 2223 | |||
| 2224 | 169 | void set_dump_thread_flag() { m_kill_dump_threads_flag = true; } | |
| 2225 | |||
| 2226 | 10103 | int get_dump_thread_count() const { return m_dump_thread_count; } | |
| 2227 | |||
| 2228 | 20857 | void operator()(THD *killing_thd) override { | |
| 2229 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20857 times.
|
20857 | DBUG_PRINT("quit", ("Informing thread %u that it's time to die", |
| 2230 | killing_thd->thread_id())); | ||
| 2231 |
2/2✓ Branch 0 taken 19872 times.
✓ Branch 1 taken 985 times.
|
20857 | if (!m_kill_dump_threads_flag) { |
| 2232 | // We skip slave threads & scheduler on this first loop through. | ||
| 2233 |
2/2✓ Branch 0 taken 1127 times.
✓ Branch 1 taken 18745 times.
|
19872 | if (killing_thd->slave_thread) return; |
| 2234 | |||
| 2235 |
6/6✓ Branch 0 taken 18637 times.
✓ Branch 1 taken 108 times.
✓ Branch 2 taken 66 times.
✓ Branch 3 taken 18571 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 18571 times.
|
37382 | if (killing_thd->get_command() == COM_BINLOG_DUMP || |
| 2236 | 18637 | killing_thd->get_command() == COM_BINLOG_DUMP_GTID) { | |
| 2237 | 174 | ++m_dump_thread_count; | |
| 2238 | 174 | return; | |
| 2239 | } | ||
| 2240 |
1/6✗ Branch 0 not taken.
✓ Branch 1 taken 18571 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
18571 | DBUG_EXECUTE_IF("Check_dump_thread_is_alive", { |
| 2241 | assert(killing_thd->get_command() != COM_BINLOG_DUMP && | ||
| 2242 | killing_thd->get_command() != COM_BINLOG_DUMP_GTID); | ||
| 2243 | };); | ||
| 2244 | } | ||
| 2245 | 19556 | mysql_mutex_lock(&killing_thd->LOCK_thd_data); | |
| 2246 | |||
| 2247 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 19546 times.
|
19556 | if (killing_thd->kill_immunizer) { |
| 2248 | /* | ||
| 2249 | If killing_thd is in kill immune mode (i.e. operation on new DD tables | ||
| 2250 | is in progress) then just save state_to_set with THD::kill_immunizer | ||
| 2251 | object. | ||
| 2252 | |||
| 2253 | While exiting kill immune mode, awake() is called again with the killed | ||
| 2254 | state saved in THD::kill_immunizer object. | ||
| 2255 | */ | ||
| 2256 | 10 | killing_thd->kill_immunizer->save_killed_state(THD::KILL_CONNECTION); | |
| 2257 | } else { | ||
| 2258 | 19546 | killing_thd->killed = THD::KILL_CONNECTION; | |
| 2259 | |||
| 2260 |
3/4✓ Branch 0 taken 24 times.
✓ Branch 1 taken 19522 times.
✓ Branch 2 taken 24 times.
✗ Branch 3 not taken.
|
19546 | MYSQL_CALLBACK(killing_thd->scheduler, post_kill_notification, |
| 2261 | (killing_thd)); | ||
| 2262 | } | ||
| 2263 | |||
| 2264 |
3/4✓ Branch 0 taken 19556 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19546 times.
✓ Branch 3 taken 10 times.
|
19556 | if (killing_thd->is_killable && killing_thd->kill_immunizer == nullptr) { |
| 2265 | 19546 | mysql_mutex_lock(&killing_thd->LOCK_current_cond); | |
| 2266 |
2/2✓ Branch 0 taken 10166 times.
✓ Branch 1 taken 9380 times.
|
19546 | if (killing_thd->current_cond.load()) { |
| 2267 | 10166 | mysql_mutex_lock(killing_thd->current_mutex); | |
| 2268 | 10166 | mysql_cond_broadcast(killing_thd->current_cond); | |
| 2269 | 10166 | mysql_mutex_unlock(killing_thd->current_mutex); | |
| 2270 | } | ||
| 2271 | 19546 | mysql_mutex_unlock(&killing_thd->LOCK_current_cond); | |
| 2272 | } | ||
| 2273 | 19556 | mysql_mutex_unlock(&killing_thd->LOCK_thd_data); | |
| 2274 | } | ||
| 2275 | }; | ||
| 2276 | |||
| 2277 | /** | ||
| 2278 | This class implements callback function used by close_connections() | ||
| 2279 | to close vio connection for all thds in thd list | ||
| 2280 | */ | ||
| 2281 | class Call_close_conn : public Do_THD_Impl { | ||
| 2282 | public: | ||
| 2283 | 10103 | Call_close_conn(bool server_shutdown) : is_server_shutdown(server_shutdown) {} | |
| 2284 | |||
| 2285 | 3787 | void operator()(THD *closing_thd) override { | |
| 2286 |
2/2✓ Branch 0 taken 3262 times.
✓ Branch 1 taken 525 times.
|
3787 | if (closing_thd->get_protocol()->connection_alive()) { |
| 2287 |
1/2✓ Branch 0 taken 3262 times.
✗ Branch 1 not taken.
|
3262 | LEX_CSTRING main_sctx_user = closing_thd->m_main_security_ctx.user(); |
| 2288 |
9/18✓ Branch 0 taken 3262 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3262 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3262 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3262 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3262 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3262 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3262 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3262 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3262 times.
✗ Branch 17 not taken.
|
3262 | LogErr(WARNING_LEVEL, ER_FORCE_CLOSE_THREAD, my_progname, |
| 2289 | (long)closing_thd->thread_id(), | ||
| 2290 | (main_sctx_user.length ? main_sctx_user.str : "")); | ||
| 2291 | /* | ||
| 2292 | Do not generate MYSQL_AUDIT_CONNECTION_DISCONNECT event, when closing | ||
| 2293 | thread close sessions. Each session will generate DISCONNECT event by | ||
| 2294 | itself. | ||
| 2295 | */ | ||
| 2296 |
1/2✓ Branch 0 taken 3262 times.
✗ Branch 1 not taken.
|
3262 | close_connection(closing_thd, 0, is_server_shutdown, false); |
| 2297 | } | ||
| 2298 | 3787 | } | |
| 2299 | |||
| 2300 | private: | ||
| 2301 | bool is_server_shutdown; | ||
| 2302 | }; | ||
| 2303 | |||
| 2304 | 10103 | static void close_connections(void) { | |
| 2305 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | DBUG_TRACE; |
| 2306 |
4/6✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1507 times.
✓ Branch 3 taken 8596 times.
✓ Branch 4 taken 1507 times.
✗ Branch 5 not taken.
|
10103 | (void)RUN_HOOK(server_state, before_server_shutdown, (nullptr)); |
| 2307 | |||
| 2308 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | Per_thread_connection_handler::kill_blocked_pthreads(); |
| 2309 | |||
| 2310 | 10103 | uint dump_thread_count = 0; | |
| 2311 | 10103 | uint dump_thread_kill_retries = 8; | |
| 2312 | |||
| 2313 | // Close listeners. | ||
| 2314 |
2/2✓ Branch 0 taken 9817 times.
✓ Branch 1 taken 286 times.
|
10103 | if (mysqld_socket_acceptor != nullptr) |
| 2315 |
1/2✓ Branch 0 taken 9817 times.
✗ Branch 1 not taken.
|
9817 | mysqld_socket_acceptor->close_listener(); |
| 2316 | #ifdef _WIN32 | ||
| 2317 | if (named_pipe_acceptor != NULL) named_pipe_acceptor->close_listener(); | ||
| 2318 | |||
| 2319 | if (shared_mem_acceptor != NULL) shared_mem_acceptor->close_listener(); | ||
| 2320 | #endif | ||
| 2321 | |||
| 2322 | /* | ||
| 2323 | First signal all threads that it's time to die | ||
| 2324 | This will give the threads some time to gracefully abort their | ||
| 2325 | statements and inform their clients that the server is about to die. | ||
| 2326 | */ | ||
| 2327 | |||
| 2328 | 10103 | Global_THD_manager *thd_manager = Global_THD_manager::get_instance(); | |
| 2329 |
8/16✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10103 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10103 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10103 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10103 times.
✗ Branch 15 not taken.
|
10103 | LogErr(INFORMATION_LEVEL, ER_DEPART_WITH_GRACE, |
| 2330 | static_cast<int>(thd_manager->get_thd_count())); | ||
| 2331 | |||
| 2332 | 10103 | Set_kill_conn set_kill_conn; | |
| 2333 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | thd_manager->do_for_all_thd(&set_kill_conn); |
| 2334 |
8/16✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10103 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10103 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10103 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10103 times.
✗ Branch 15 not taken.
|
10103 | LogErr(INFORMATION_LEVEL, ER_SHUTTING_DOWN_SLAVE_THREADS); |
| 2335 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | end_slave(); |
| 2336 | |||
| 2337 |
2/2✓ Branch 0 taken 169 times.
✓ Branch 1 taken 9934 times.
|
10103 | if (set_kill_conn.get_dump_thread_count()) { |
| 2338 | /* | ||
| 2339 | Replication dump thread should be terminated after the clients are | ||
| 2340 | terminated. Wait for few more seconds for other sessions to end. | ||
| 2341 | */ | ||
| 2342 |
5/6✓ Branch 0 taken 1521 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1352 times.
✓ Branch 3 taken 169 times.
✓ Branch 4 taken 1352 times.
✓ Branch 5 taken 169 times.
|
1521 | while (thd_manager->get_thd_count() > dump_thread_count && |
| 2343 | dump_thread_kill_retries) { | ||
| 2344 |
1/2✓ Branch 0 taken 1352 times.
✗ Branch 1 not taken.
|
1352 | sleep(1); |
| 2345 | 1352 | dump_thread_kill_retries--; | |
| 2346 | } | ||
| 2347 | 169 | set_kill_conn.set_dump_thread_flag(); | |
| 2348 |
1/2✓ Branch 0 taken 169 times.
✗ Branch 1 not taken.
|
169 | thd_manager->do_for_all_thd(&set_kill_conn); |
| 2349 | } | ||
| 2350 | |||
| 2351 | // Disable the event scheduler | ||
| 2352 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | Events::stop(); |
| 2353 | |||
| 2354 |
3/4✓ Branch 0 taken 4932 times.
✓ Branch 1 taken 5171 times.
✓ Branch 2 taken 4932 times.
✗ Branch 3 not taken.
|
10103 | if (thd_manager->get_thd_count() > 0) sleep(2); // Give threads time to die |
| 2355 | |||
| 2356 | /* | ||
| 2357 | Force remaining threads to die by closing the connection to the client | ||
| 2358 | This will ensure that threads that are waiting for a command from the | ||
| 2359 | client on a blocking read call are aborted. | ||
| 2360 | */ | ||
| 2361 | |||
| 2362 |
8/16✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10103 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10103 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10103 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10103 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10103 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 10103 times.
✗ Branch 15 not taken.
|
10103 | LogErr(INFORMATION_LEVEL, ER_DISCONNECTING_REMAINING_CLIENTS, |
| 2363 | static_cast<int>(thd_manager->get_thd_count())); | ||
| 2364 | |||
| 2365 | 10103 | Call_close_conn call_close_conn(true); | |
| 2366 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | thd_manager->do_for_all_thd(&call_close_conn); |
| 2367 | |||
| 2368 |
4/6✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1507 times.
✓ Branch 3 taken 8596 times.
✓ Branch 4 taken 1507 times.
✗ Branch 5 not taken.
|
10103 | (void)RUN_HOOK(server_state, after_server_shutdown, (nullptr)); |
| 2369 | |||
| 2370 | /* | ||
| 2371 | All threads have now been aborted. Stop event scheduler thread | ||
| 2372 | after aborting all client connections, otherwise user may | ||
| 2373 | start/stop event scheduler after Events::deinit() deallocates | ||
| 2374 | scheduler object(static member in Events class) | ||
| 2375 | */ | ||
| 2376 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | Events::deinit(); |
| 2377 |
3/8✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10103 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
10103 | DBUG_PRINT("quit", ("Waiting for threads to die (count=%u)", |
| 2378 | thd_manager->get_thd_count())); | ||
| 2379 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | thd_manager->wait_till_no_thd(); |
| 2380 | /* | ||
| 2381 | Connection threads might take a little while to go down after removing from | ||
| 2382 | global thread list. Give it some time. | ||
| 2383 | */ | ||
| 2384 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | Connection_handler_manager::wait_till_no_connection(); |
| 2385 | |||
| 2386 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | delete_slave_info_objects(); |
| 2387 |
3/8✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10103 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
10103 | DBUG_PRINT("quit", ("close_connections thread")); |
| 2388 | 10103 | } | |
| 2389 | |||
| 2390 | 58 | bool signal_restart_server() { | |
| 2391 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 56 times.
|
58 | if (!is_mysqld_managed()) { |
| 2392 | 2 | my_error(ER_RESTART_SERVER_FAILED, MYF(0), | |
| 2393 | "mysqld is not managed by supervisor process"); | ||
| 2394 | 2 | return true; | |
| 2395 | } | ||
| 2396 | |||
| 2397 | #ifdef _WIN32 | ||
| 2398 | if (!SetEvent(hEventRestart)) { | ||
| 2399 | LogErr(ERROR_LEVEL, ER_SET_EVENT_FAILED, GetLastError()); | ||
| 2400 | my_error(ER_RESTART_SERVER_FAILED, MYF(0), "Internal operation failure"); | ||
| 2401 | return true; | ||
| 2402 | } | ||
| 2403 | #else | ||
| 2404 | |||
| 2405 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
|
56 | if (pthread_kill(signal_thread_id.thread, SIGUSR2)) { |
| 2406 | ✗ | DBUG_PRINT("error", ("Got error %d from pthread_kill", errno)); | |
| 2407 | ✗ | my_error(ER_RESTART_SERVER_FAILED, MYF(0), "Internal operation failure"); | |
| 2408 | ✗ | return true; | |
| 2409 | } | ||
| 2410 | #endif | ||
| 2411 | 56 | return false; | |
| 2412 | } | ||
| 2413 | |||
| 2414 | 9756 | void kill_mysql(void) { | |
| 2415 |
1/2✓ Branch 0 taken 9756 times.
✗ Branch 1 not taken.
|
9756 | DBUG_TRACE; |
| 2416 | |||
| 2417 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 9752 times.
|
9756 | if (!mysqld_server_started) { |
| 2418 | 4 | mysqld_process_must_end_at_startup = true; | |
| 2419 | 4 | return; | |
| 2420 | } | ||
| 2421 | #if defined(_WIN32) | ||
| 2422 | { | ||
| 2423 | if (!SetEvent(hEventShutdown)) { | ||
| 2424 | DBUG_PRINT("error", ("Got error: %ld from SetEvent", GetLastError())); | ||
| 2425 | } | ||
| 2426 | /* | ||
| 2427 | or: | ||
| 2428 | HANDLE hEvent=OpenEvent(0, false, "MySqlShutdown"); | ||
| 2429 | SetEvent(hEventShutdown); | ||
| 2430 | CloseHandle(hEvent); | ||
| 2431 | */ | ||
| 2432 | } | ||
| 2433 | #else | ||
| 2434 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9752 times.
|
9752 | if (pthread_kill(signal_thread_id.thread, SIGTERM)) { |
| 2435 | ✗ | DBUG_PRINT("error", ("Got error %d from pthread_kill", | |
| 2436 | errno)); /* purecov: inspected */ | ||
| 2437 | } | ||
| 2438 | #endif | ||
| 2439 |
5/8✓ Branch 0 taken 9752 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9752 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 9751 times.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
|
9752 | DBUG_PRINT("quit", ("After pthread_kill")); |
| 2440 |
2/2✓ Branch 0 taken 9752 times.
✓ Branch 1 taken 4 times.
|
9756 | } |
| 2441 | |||
| 2442 | 696 | static void unireg_abort(int exit_code) { | |
| 2443 |
1/2✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
|
696 | DBUG_TRACE; |
| 2444 | |||
| 2445 |
2/2✓ Branch 0 taken 276 times.
✓ Branch 1 taken 420 times.
|
696 | if (errno) { |
| 2446 |
1/2✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
|
276 | sysd::notify("ERRNO=", errno, "\n"); |
| 2447 | } | ||
| 2448 | |||
| 2449 |
5/6✓ Branch 0 taken 301 times.
✓ Branch 1 taken 395 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 281 times.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
|
696 | if (opt_initialize && exit_code && !opt_validate_config) |
| 2450 |
12/20✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10 times.
✓ Branch 5 taken 10 times.
✓ Branch 6 taken 20 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 20 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 20 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 20 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 10 times.
✓ Branch 17 taken 10 times.
✓ Branch 18 taken 20 times.
✗ Branch 19 not taken.
|
20 | LogErr(ERROR_LEVEL, |
| 2451 | mysql_initialize_directory_freshly_created | ||
| 2452 | ? ER_DATA_DIRECTORY_UNUSABLE_DELETABLE | ||
| 2453 | : ER_DATA_DIRECTORY_UNUSABLE, | ||
| 2454 | mysql_real_data_home); | ||
| 2455 | |||
| 2456 | // At this point it does not make sense to buffer more messages. | ||
| 2457 | // Just flush what we have and write directly to stderr. | ||
| 2458 |
1/2✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
|
696 | flush_error_log_messages(); |
| 2459 | |||
| 2460 |
3/4✓ Branch 0 taken 14 times.
✓ Branch 1 taken 682 times.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
|
696 | if (opt_help) usage(); |
| 2461 | |||
| 2462 | bool daemon_launcher_quiet = | ||
| 2463 |
5/6✓ Branch 0 taken 4 times.
✓ Branch 1 taken 692 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 1 times.
|
699 | (IF_WIN(false, opt_daemonize) && !mysqld::runtime::is_daemon() && |
| 2464 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | !is_help_or_validate_option()); |
| 2465 | |||
| 2466 |
12/20✓ Branch 0 taken 693 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 388 times.
✓ Branch 3 taken 305 times.
✓ Branch 4 taken 388 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 388 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 388 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 388 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 388 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 388 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 388 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 388 times.
✗ Branch 19 not taken.
|
696 | if (!daemon_launcher_quiet && exit_code) LogErr(ERROR_LEVEL, ER_ABORTING); |
| 2467 | |||
| 2468 |
1/2✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
|
696 | mysql_audit_notify(MYSQL_AUDIT_SERVER_SHUTDOWN_SHUTDOWN, |
| 2469 | MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_ABORT, exit_code); | ||
| 2470 | #ifndef _WIN32 | ||
| 2471 |
2/2✓ Branch 0 taken 290 times.
✓ Branch 1 taken 406 times.
|
696 | if (signal_thread_id.thread != 0) { |
| 2472 | // Make sure the signal thread isn't blocked when we are trying to exit. | ||
| 2473 |
1/2✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
|
290 | server_components_initialized(); |
| 2474 | |||
| 2475 | 290 | pthread_kill(signal_thread_id.thread, SIGTERM); | |
| 2476 |
1/2✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
|
290 | my_thread_join(&signal_thread_id, nullptr); |
| 2477 | } | ||
| 2478 | 696 | signal_thread_id.thread = 0; | |
| 2479 | |||
| 2480 |
3/4✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 695 times.
|
696 | if (mysqld::runtime::is_daemon()) { |
| 2481 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | mysqld::runtime::signal_parent(pipe_write_fd, 0); |
| 2482 | } | ||
| 2483 | #endif | ||
| 2484 |
7/8✓ Branch 0 taken 677 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 674 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 289 times.
✓ Branch 5 taken 385 times.
✓ Branch 6 taken 696 times.
✗ Branch 7 not taken.
|
985 | clean_up(!is_help_or_validate_option() && !daemon_launcher_quiet && |
| 2485 |
2/2✓ Branch 0 taken 9 times.
✓ Branch 1 taken 280 times.
|
289 | (exit_code || !opt_initialize)); /* purecov: inspected */ |
| 2486 |
3/8✓ Branch 0 taken 696 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 696 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 696 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
696 | DBUG_PRINT("quit", ("done with cleanup in unireg_abort")); |
| 2487 | 696 | mysqld_exit(exit_code); | |
| 2488 | } | ||
| 2489 | |||
| 2490 | 33 | void clean_up_mysqld_mutexes() { clean_up_mutexes(); } | |
| 2491 | |||
| 2492 | 10491 | static void mysqld_exit(int exit_code) { | |
| 2493 |
4/6✓ Branch 0 taken 10491 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10435 times.
✓ Branch 3 taken 56 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 56 times.
|
10491 | assert((exit_code >= MYSQLD_SUCCESS_EXIT && exit_code <= MYSQLD_ABORT_EXIT) || |
| 2494 | exit_code == MYSQLD_RESTART_EXIT); | ||
| 2495 | 10491 | mysql_audit_finalize(); | |
| 2496 | 10491 | Srv_session::module_deinit(); | |
| 2497 | 10491 | delete_optimizer_cost_module(); | |
| 2498 | 10491 | clean_up_mutexes(); | |
| 2499 |
2/2✓ Branch 0 taken 234 times.
✓ Branch 1 taken 10257 times.
|
10491 | my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); |
| 2500 | 10491 | destroy_error_log(); | |
| 2501 | 10491 | log_error_read_log_exit(); | |
| 2502 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 2503 | 10491 | shutdown_performance_schema(); | |
| 2504 | #endif | ||
| 2505 | |||
| 2506 | #ifdef WITH_LOCK_ORDER | ||
| 2507 | LO_cleanup(); | ||
| 2508 | #endif | ||
| 2509 | |||
| 2510 | #if defined(_WIN32) | ||
| 2511 | if (hEventShutdown) CloseHandle(hEventShutdown); | ||
| 2512 | close_service_status_pipe_in_mysqld(); | ||
| 2513 | #endif // _WIN32 | ||
| 2514 | |||
| 2515 | 10491 | exit(exit_code); /* purecov: inspected */ | |
| 2516 | } | ||
| 2517 | |||
| 2518 | /** | ||
| 2519 | GTID cleanup destroys objects and reset their pointer. | ||
| 2520 | Function is reentrant. | ||
| 2521 | */ | ||
| 2522 | 10524 | void gtid_server_cleanup() { | |
| 2523 |
2/2✓ Branch 0 taken 10469 times.
✓ Branch 1 taken 55 times.
|
10524 | if (gtid_state != nullptr) { |
| 2524 |
1/2✓ Branch 0 taken 10469 times.
✗ Branch 1 not taken.
|
10469 | delete gtid_state; |
| 2525 | 10469 | gtid_state = nullptr; | |
| 2526 | } | ||
| 2527 |
2/2✓ Branch 0 taken 10469 times.
✓ Branch 1 taken 55 times.
|
10524 | if (global_sid_map != nullptr) { |
| 2528 |
1/2✓ Branch 0 taken 10469 times.
✗ Branch 1 not taken.
|
10469 | delete global_sid_map; |
| 2529 | 10469 | global_sid_map = nullptr; | |
| 2530 | } | ||
| 2531 |
2/2✓ Branch 0 taken 10469 times.
✓ Branch 1 taken 55 times.
|
10524 | if (global_sid_lock != nullptr) { |
| 2532 |
1/2✓ Branch 0 taken 10469 times.
✗ Branch 1 not taken.
|
10469 | delete global_sid_lock; |
| 2533 | 10469 | global_sid_lock = nullptr; | |
| 2534 | } | ||
| 2535 |
2/2✓ Branch 0 taken 10469 times.
✓ Branch 1 taken 55 times.
|
10524 | if (gtid_table_persistor != nullptr) { |
| 2536 |
1/2✓ Branch 0 taken 10469 times.
✗ Branch 1 not taken.
|
10469 | delete gtid_table_persistor; |
| 2537 | 10469 | gtid_table_persistor = nullptr; | |
| 2538 | } | ||
| 2539 | 10524 | } | |
| 2540 | |||
| 2541 | /** | ||
| 2542 | GTID initialization. | ||
| 2543 | |||
| 2544 | @return true if allocation does not succeed | ||
| 2545 | false if OK | ||
| 2546 | */ | ||
| 2547 | 12087 | bool gtid_server_init() { | |
| 2548 | 12087 | global_gtid_mode.set( | |
| 2549 | static_cast<Gtid_mode::value_type>(Gtid_mode::sysvar_mode)); | ||
| 2550 | 12087 | bool res = (!(global_sid_lock = new Checkable_rwlock( | |
| 2551 | #ifdef HAVE_PSI_INTERFACE | ||
| 2552 | key_rwlock_global_sid_lock | ||
| 2553 | #endif | ||
| 2554 |
1/2✓ Branch 0 taken 12087 times.
✗ Branch 1 not taken.
|
12087 | )) || |
| 2555 |
2/4✓ Branch 0 taken 12087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12087 times.
✗ Branch 3 not taken.
|
12087 | !(global_sid_map = new Sid_map(global_sid_lock)) || |
| 2556 |
3/6✓ Branch 0 taken 12087 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12087 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12087 times.
✗ Branch 5 not taken.
|
36261 | !(gtid_state = new Gtid_state(global_sid_lock, global_sid_map)) || |
| 2557 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12087 times.
|
12087 | !(gtid_table_persistor = new Gtid_table_persistor())); |
| 2558 | |||
| 2559 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12087 times.
|
12087 | if (res) { |
| 2560 | ✗ | gtid_server_cleanup(); | |
| 2561 | } | ||
| 2562 | 12087 | return res; | |
| 2563 | } | ||
| 2564 | |||
| 2565 | // Free connection acceptors | ||
| 2566 | 10491 | static void free_connection_acceptors() { | |
| 2567 |
2/2✓ Branch 0 taken 9833 times.
✓ Branch 1 taken 658 times.
|
10491 | delete mysqld_socket_acceptor; |
| 2568 | 10491 | mysqld_socket_acceptor = nullptr; | |
| 2569 | |||
| 2570 | #ifdef _WIN32 | ||
| 2571 | delete named_pipe_acceptor; | ||
| 2572 | named_pipe_acceptor = NULL; | ||
| 2573 | delete shared_mem_acceptor; | ||
| 2574 | shared_mem_acceptor = NULL; | ||
| 2575 | #endif | ||
| 2576 | 10491 | } | |
| 2577 | |||
| 2578 | 10509 | static void clean_up(bool print_message) { | |
| 2579 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10509 times.
|
10509 | DBUG_PRINT("exit", ("clean_up")); |
| 2580 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10509 times.
|
10509 | if (cleanup_done++) return; /* purecov: inspected */ |
| 2581 | |||
| 2582 | 10509 | ha_pre_dd_shutdown(); | |
| 2583 | 10491 | dd::shutdown(); | |
| 2584 | |||
| 2585 | 10491 | Events::deinit(); | |
| 2586 | 10491 | stop_handle_manager(); | |
| 2587 | |||
| 2588 | 10491 | memcached_shutdown(); | |
| 2589 | |||
| 2590 | 10491 | release_keyring_handles(); | |
| 2591 | 10491 | keyring_lockable_deinit(); | |
| 2592 | |||
| 2593 | /* | ||
| 2594 | make sure that handlers finish up | ||
| 2595 | what they have that is dependent on the binlog | ||
| 2596 | */ | ||
| 2597 |
5/8✓ Branch 0 taken 10189 times.
✓ Branch 1 taken 302 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 10189 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 10189 times.
✓ Branch 7 taken 302 times.
|
10491 | if (print_message && (!is_help_or_validate_option() || opt_verbose)) |
| 2598 |
7/14✓ Branch 0 taken 10189 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10189 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10189 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10189 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10189 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10189 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10189 times.
✗ Branch 13 not taken.
|
10189 | LogErr(INFORMATION_LEVEL, ER_BINLOG_END); |
| 2599 | 10491 | ha_binlog_end(current_thd); | |
| 2600 | |||
| 2601 | 10491 | injector::free_instance(); | |
| 2602 | 10491 | mysql_bin_log.cleanup(); | |
| 2603 | |||
| 2604 | 10491 | udf_load_service.deinit(); | |
| 2605 |
2/2✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 337 times.
|
10491 | delete rpl_source_io_monitor; |
| 2606 | 10491 | rpl_source_io_monitor = nullptr; | |
| 2607 |
2/2✓ Branch 0 taken 10154 times.
✓ Branch 1 taken 337 times.
|
10491 | delete rpl_acf_configuration_handler; |
| 2608 | 10491 | rpl_acf_configuration_handler = nullptr; | |
| 2609 | |||
| 2610 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 10459 times.
|
10491 | if (use_slave_mask) bitmap_free(&slave_error_mask); |
| 2611 | 10491 | my_tz_free(); | |
| 2612 | 10491 | servers_free(true); | |
| 2613 | 10491 | acl_free(true); | |
| 2614 | 10491 | grant_free(); | |
| 2615 | 10491 | hostname_cache_free(); | |
| 2616 | 10491 | range_optimizer_free(); | |
| 2617 | 10491 | item_func_sleep_free(); | |
| 2618 | 10491 | lex_free(); /* Free some memory */ | |
| 2619 | 10491 | item_create_cleanup(); | |
| 2620 |
2/2✓ Branch 0 taken 10144 times.
✓ Branch 1 taken 347 times.
|
10491 | if (!opt_noacl) udf_unload_udfs(); |
| 2621 | 10491 | table_def_start_shutdown(); | |
| 2622 | 10491 | delegates_shutdown(); | |
| 2623 | 10491 | plugin_shutdown(); | |
| 2624 | 10491 | gtid_server_cleanup(); // after plugin_shutdown | |
| 2625 | 10491 | delete_optimizer_cost_module(); | |
| 2626 | 10491 | ha_end(); | |
| 2627 |
2/2✓ Branch 0 taken 622 times.
✓ Branch 1 taken 9869 times.
|
10491 | if (tc_log) { |
| 2628 | 622 | tc_log->close(); | |
| 2629 | 622 | tc_log = nullptr; | |
| 2630 | } | ||
| 2631 | |||
| 2632 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 10473 times.
|
10491 | if (dd::upgrade_57::in_progress()) delete_dictionary_tablespace(); |
| 2633 | |||
| 2634 | 10491 | Recovered_xa_transactions::destroy(); | |
| 2635 | 10491 | delegates_destroy(); | |
| 2636 | 10491 | xa::Transaction_cache::dispose(); | |
| 2637 | 10491 | MDL_context_backup_manager::destroy(); | |
| 2638 | 10491 | table_def_free(); | |
| 2639 | 10491 | mdl_destroy(); | |
| 2640 | 10491 | key_caches.delete_elements(); | |
| 2641 | 10491 | multi_keycache_free(); | |
| 2642 | 10491 | query_logger.cleanup(); | |
| 2643 | 10491 | free_tmpdir(&mysql_tmpdir_list); | |
| 2644 | 10491 | my_free(opt_bin_logname); | |
| 2645 | 10491 | free_max_user_conn(); | |
| 2646 | 10491 | free_global_user_stats(); | |
| 2647 | 10491 | free_global_client_stats(); | |
| 2648 | 10491 | free_global_thread_stats(); | |
| 2649 | 10491 | free_global_table_stats(); | |
| 2650 | 10491 | free_global_index_stats(); | |
| 2651 |
1/2✓ Branch 0 taken 10491 times.
✗ Branch 1 not taken.
|
10491 | delete binlog_filter; |
| 2652 | 10491 | rpl_channel_filters.clean_up(); | |
| 2653 | 10491 | end_ssl(); | |
| 2654 | 10491 | vio_end(); | |
| 2655 | 10491 | u_cleanup(); | |
| 2656 | #if defined(ENABLED_DEBUG_SYNC) | ||
| 2657 | /* End the debug sync facility. See debug_sync.cc. */ | ||
| 2658 | 10491 | debug_sync_end(); | |
| 2659 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 2660 | |||
| 2661 | 10491 | delete_pid_file(MYF(0)); | |
| 2662 | |||
| 2663 |
5/6✓ Branch 0 taken 10189 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 10156 times.
✓ Branch 3 taken 33 times.
✓ Branch 4 taken 10156 times.
✗ Branch 5 not taken.
|
10491 | if (print_message && my_default_lc_messages && server_start_time) |
| 2664 |
7/14✓ Branch 0 taken 10156 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10156 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 10156 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 10156 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 10156 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 10156 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 10156 times.
✗ Branch 13 not taken.
|
10156 | LogErr(SYSTEM_LEVEL, ER_SERVER_SHUTDOWN_COMPLETE, my_progname, |
| 2665 | server_version, MYSQL_COMPILATION_COMMENT_SERVER); | ||
| 2666 | 10491 | cleanup_errmsgs(); | |
| 2667 | |||
| 2668 | 10491 | sysd::notify("STATUS=Server shutdown complete"); | |
| 2669 | |||
| 2670 | 10491 | free_connection_acceptors(); | |
| 2671 | 10491 | Connection_handler_manager::destroy_instance(); | |
| 2672 | |||
| 2673 |
6/6✓ Branch 0 taken 10472 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 10172 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 10172 times.
✓ Branch 5 taken 319 times.
|
10491 | if (!is_help_or_validate_option() && !opt_initialize) |
| 2674 | 10172 | resourcegroups::Resource_group_mgr::destroy_instance(); | |
| 2675 | 10491 | mysql_client_plugin_deinit(); | |
| 2676 | |||
| 2677 | 10491 | Global_THD_manager::destroy_instance(); | |
| 2678 | |||
| 2679 | 10491 | my_free(const_cast<char *>(log_bin_basename)); | |
| 2680 | 10491 | my_free(const_cast<char *>(log_bin_index)); | |
| 2681 | 10491 | my_free(const_cast<char *>(relay_log_basename)); | |
| 2682 | 10491 | my_free(const_cast<char *>(relay_log_index)); | |
| 2683 | 10491 | free_list(opt_early_plugin_load_list_ptr); | |
| 2684 | 10491 | free_list(opt_plugin_load_list_ptr); | |
| 2685 | |||
| 2686 | /* | ||
| 2687 | Is this the best place for components deinit? It may be changed when new | ||
| 2688 | dependencies are discovered, possibly being divided into separate points | ||
| 2689 | where all dependencies are still ok. | ||
| 2690 | */ | ||
| 2691 | 10491 | log_error_stage_set(LOG_ERROR_STAGE_SHUTTING_DOWN); | |
| 2692 | 10491 | log_builtins_error_stack(LOG_ERROR_SERVICES_DEFAULT, false, nullptr); | |
| 2693 | #ifdef HAVE_PSI_THREAD_INTERFACE | ||
| 2694 |
6/6✓ Branch 0 taken 10472 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 10172 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 10172 times.
✓ Branch 5 taken 319 times.
|
10491 | if (!is_help_or_validate_option() && !opt_initialize) { |
| 2695 | 10172 | unregister_pfs_notification_service(); | |
| 2696 | 10172 | unregister_pfs_resource_group_service(); | |
| 2697 | } | ||
| 2698 | #endif | ||
| 2699 | 10491 | deinit_tls_psi_keys(); | |
| 2700 | 10491 | deinitialize_manifest_file_components(); | |
| 2701 | 10491 | component_infrastructure_deinit(); | |
| 2702 | /* | ||
| 2703 | component unregister_variable() api depends on system_variable_hash. | ||
| 2704 | component_infrastructure_deinit() interns calls the deinit function | ||
| 2705 | of components which are loaded, and the deinit functions can have | ||
| 2706 | the component system unregister_ variable() api's, hence we need | ||
| 2707 | to call the sys_var_end() after component_infrastructure_deinit() | ||
| 2708 | */ | ||
| 2709 | 10491 | sys_var_end(); | |
| 2710 | 10491 | free_status_vars(); | |
| 2711 | |||
| 2712 | 10491 | finish_client_errs(); | |
| 2713 | 10491 | deinit_errmessage(); // finish server errs | |
| 2714 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10491 times.
|
10491 | DBUG_PRINT("quit", ("Error messages freed")); |
| 2715 | |||
| 2716 |
2/2✓ Branch 0 taken 10422 times.
✓ Branch 1 taken 69 times.
|
10491 | if (have_statement_timeout == SHOW_OPTION_YES) my_timer_deinitialize(); |
| 2717 | |||
| 2718 | 10491 | have_statement_timeout = SHOW_OPTION_DISABLED; | |
| 2719 | |||
| 2720 | 10491 | persisted_variables_cache.cleanup(); | |
| 2721 | |||
| 2722 | 10491 | udf_deinit_globals(); | |
| 2723 | /* | ||
| 2724 | The following lines may never be executed as the main thread may have | ||
| 2725 | killed us | ||
| 2726 | */ | ||
| 2727 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10491 times.
|
10491 | DBUG_PRINT("quit", ("done with cleanup")); |
| 2728 | } /* clean_up */ | ||
| 2729 | |||
| 2730 | 10524 | static void clean_up_mutexes() { | |
| 2731 | 10524 | mysql_mutex_destroy(&LOCK_log_throttle_qni); | |
| 2732 | 10524 | mysql_mutex_destroy(&LOCK_status); | |
| 2733 | 10524 | mysql_mutex_destroy(&LOCK_manager); | |
| 2734 | 10524 | mysql_mutex_destroy(&LOCK_crypt); | |
| 2735 | 10524 | mysql_mutex_destroy(&LOCK_user_conn); | |
| 2736 | 10524 | mysql_rwlock_destroy(&LOCK_sys_init_connect); | |
| 2737 | 10524 | mysql_rwlock_destroy(&LOCK_sys_init_replica); | |
| 2738 | 10524 | mysql_mutex_destroy(&LOCK_global_system_variables); | |
| 2739 | 10524 | mysql_rwlock_destroy(&LOCK_system_variables_hash); | |
| 2740 | 10524 | mysql_mutex_destroy(&LOCK_uuid_generator); | |
| 2741 | 10524 | mysql_mutex_destroy(&LOCK_sql_rand); | |
| 2742 | 10524 | mysql_mutex_destroy(&LOCK_prepared_stmt_count); | |
| 2743 | 10524 | mysql_mutex_destroy(&LOCK_replica_list); | |
| 2744 | 10524 | mysql_mutex_destroy(&LOCK_sql_replica_skip_counter); | |
| 2745 | 10524 | mysql_mutex_destroy(&LOCK_replica_net_timeout); | |
| 2746 | 10524 | mysql_mutex_destroy(&LOCK_replica_trans_dep_tracker); | |
| 2747 | 10524 | mysql_mutex_destroy(&LOCK_error_messages); | |
| 2748 | 10524 | mysql_mutex_destroy(&LOCK_default_password_lifetime); | |
| 2749 | 10524 | mysql_mutex_destroy(&LOCK_mandatory_roles); | |
| 2750 | 10524 | mysql_mutex_destroy(&LOCK_server_started); | |
| 2751 | 10524 | mysql_cond_destroy(&COND_server_started); | |
| 2752 | 10524 | mysql_mutex_destroy(&LOCK_reset_gtid_table); | |
| 2753 | 10524 | mysql_mutex_destroy(&LOCK_compress_gtid_table); | |
| 2754 | 10524 | mysql_cond_destroy(&COND_compress_gtid_table); | |
| 2755 | 10524 | mysql_mutex_destroy(&LOCK_collect_instance_log); | |
| 2756 | 10524 | mysql_mutex_destroy(&LOCK_password_history); | |
| 2757 | 10524 | mysql_mutex_destroy(&LOCK_password_reuse_interval); | |
| 2758 | 10524 | mysql_cond_destroy(&COND_manager); | |
| 2759 | #ifdef _WIN32 | ||
| 2760 | mysql_cond_destroy(&COND_handler_count); | ||
| 2761 | mysql_mutex_destroy(&LOCK_handler_count); | ||
| 2762 | mysql_rwlock_destroy(&LOCK_named_pipe_full_access_group); | ||
| 2763 | #endif | ||
| 2764 | #ifndef _WIN32 | ||
| 2765 | 10524 | mysql_cond_destroy(&COND_socket_listener_active); | |
| 2766 | 10524 | mysql_mutex_destroy(&LOCK_socket_listener_active); | |
| 2767 | 10524 | mysql_cond_destroy(&COND_start_signal_handler); | |
| 2768 | 10524 | mysql_mutex_destroy(&LOCK_start_signal_handler); | |
| 2769 | #endif | ||
| 2770 | 10524 | mysql_mutex_destroy(&LOCK_keyring_operations); | |
| 2771 | 10524 | mysql_mutex_destroy(&LOCK_tls_ctx_options); | |
| 2772 | 10524 | mysql_mutex_destroy(&LOCK_rotate_binlog_master_key); | |
| 2773 | 10524 | mysql_mutex_destroy(&LOCK_global_user_client_stats); | |
| 2774 | 10524 | mysql_mutex_destroy(&LOCK_global_table_stats); | |
| 2775 | 10524 | mysql_mutex_destroy(&LOCK_global_index_stats); | |
| 2776 | 10524 | mysql_rwlock_destroy(&LOCK_consistent_snapshot); | |
| 2777 | 10524 | mysql_mutex_destroy(&LOCK_admin_tls_ctx_options); | |
| 2778 | 10524 | mysql_mutex_destroy(&LOCK_partial_revokes); | |
| 2779 | 10524 | mysql_mutex_destroy(&LOCK_authentication_policy); | |
| 2780 | 10524 | mysql_mutex_destroy(&LOCK_global_conn_mem_limit); | |
| 2781 | 10524 | } | |
| 2782 | |||
| 2783 | /**************************************************************************** | ||
| 2784 | ** Init IP and UNIX socket | ||
| 2785 | ****************************************************************************/ | ||
| 2786 | |||
| 2787 | /* Initialise proxy protocol. */ | ||
| 2788 | 11468 | static void set_proxy() { | |
| 2789 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 11441 times.
|
11472 | if (opt_disable_networking) return; |
| 2790 | |||
| 2791 | struct st_vio_network net; | ||
| 2792 | |||
| 2793 | /* Check for special case '*'. */ | ||
| 2794 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11437 times.
|
11441 | if (strcmp(my_proxy_protocol_networks, "*") == 0) { |
| 2795 | 4 | memset(&net, 0, sizeof(net)); | |
| 2796 | 4 | net.family = AF_INET; | |
| 2797 | 4 | vio_proxy_protocol_add(net); | |
| 2798 | 4 | net.family = AF_INET6; | |
| 2799 | 4 | vio_proxy_protocol_add(net); | |
| 2800 | 4 | return; | |
| 2801 | } | ||
| 2802 | |||
| 2803 | 11437 | const char *p = my_proxy_protocol_networks; | |
| 2804 | |||
| 2805 | while (1) { | ||
| 2806 | /* jump spaces. */ | ||
| 2807 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11454 times.
|
11454 | while (*p == ' ') p++; |
| 2808 |
2/2✓ Branch 0 taken 11426 times.
✓ Branch 1 taken 28 times.
|
11455 | if (*p == '\0') break; |
| 2809 | 28 | const char *start = p; | |
| 2810 | |||
| 2811 | /* look for separator */ | ||
| 2812 |
7/8✓ Branch 0 taken 423 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 403 times.
✓ Branch 3 taken 20 times.
✓ Branch 4 taken 403 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 397 times.
✓ Branch 7 taken 6 times.
|
425 | while (*p != ',' && *p != '/' && *p != ' ' && *p != '\0') p++; |
| 2813 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 27 times.
|
28 | if (p - start > INET6_ADDRSTRLEN) { |
| 2814 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error( |
| 2815 | "Too long network in 'proxy_protocol_networks' " | ||
| 2816 | "directive."); | ||
| 2817 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | unireg_abort(1); |
| 2818 | } | ||
| 2819 | char buffer[INET6_ADDRSTRLEN + 1 + 3 + 1]; | ||
| 2820 | 27 | memcpy(buffer, start, p - start); | |
| 2821 | 27 | buffer[p - start] = '\0'; | |
| 2822 | |||
| 2823 | /* Try to convert to ipv4. */ | ||
| 2824 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 17 times.
|
27 | if (inet_pton(AF_INET, buffer, &net.addr.in)) net.family = AF_INET; |
| 2825 | |||
| 2826 | /* Try to convert to ipv6. */ | ||
| 2827 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 5 times.
|
17 | else if (inet_pton(AF_INET6, buffer, &net.addr.in6)) |
| 2828 | 12 | net.family = AF_INET6; | |
| 2829 | |||
| 2830 | else { | ||
| 2831 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | sql_print_error( |
| 2832 | "Bad network '%s' in 'proxy_protocol_networks' " | ||
| 2833 | "directive.", | ||
| 2834 | buffer); | ||
| 2835 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
5 | unireg_abort(1); |
| 2836 | } | ||
| 2837 | |||
| 2838 | /* Look for network. */ | ||
| 2839 | unsigned bits; | ||
| 2840 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 2 times.
|
22 | if (*p == '/') { |
| 2841 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 19 times.
|
20 | if (!my_isdigit(&my_charset_bin, *++p)) { |
| 2842 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error( |
| 2843 | "Missing network prefix in 'proxy_protocol_networks' " | ||
| 2844 | "directive."); | ||
| 2845 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | unireg_abort(1); |
| 2846 | } | ||
| 2847 | 19 | start = p; | |
| 2848 | 19 | bits = 0; | |
| 2849 |
4/4✓ Branch 0 taken 40 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 39 times.
✓ Branch 3 taken 1 times.
|
58 | while (my_isdigit(&my_charset_bin, *p) && p - start < 3) |
| 2850 | 39 | bits = bits * 10 + *p++ - '0'; | |
| 2851 | |||
| 2852 | /* Check bits value. */ | ||
| 2853 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 7 times.
|
19 | if (net.family == AF_INET && bits > 32) { |
| 2854 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error( |
| 2855 | "Bad IPv4 mask in 'proxy_protocol_networks' " | ||
| 2856 | "directive."); | ||
| 2857 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | unireg_abort(1); |
| 2858 | } | ||
| 2859 |
4/4✓ Branch 0 taken 11 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 10 times.
|
18 | if (net.family == AF_INET6 && bits > 128) { |
| 2860 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error( |
| 2861 | "Bad IPv6 mask in 'proxy_protocol_networks' " | ||
| 2862 | "directive."); | ||
| 2863 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | unireg_abort(1); |
| 2864 | } | ||
| 2865 | } else { | ||
| 2866 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | if (net.family == AF_INET) |
| 2867 | 1 | bits = 32; | |
| 2868 | else { | ||
| 2869 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(net.family == AF_INET6); |
| 2870 | 1 | bits = 128; | |
| 2871 | } | ||
| 2872 | } | ||
| 2873 | |||
| 2874 | /* Build binary mask. */ | ||
| 2875 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 11 times.
|
19 | if (net.family == AF_INET) { |
| 2876 | /* Process IPv4 mask. */ | ||
| 2877 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
|
8 | if (bits == 0) |
| 2878 | 2 | net.mask.in.s_addr = 0x00000000; | |
| 2879 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
|
6 | else if (bits == 32) |
| 2880 | 2 | net.mask.in.s_addr = 0xffffffff; | |
| 2881 | else | ||
| 2882 | 4 | net.mask.in.s_addr = ~((0x80000000 >> (bits - 1)) - 1); | |
| 2883 | 8 | net.mask.in.s_addr = htonl(net.mask.in.s_addr); | |
| 2884 | |||
| 2885 | /* Apply mask */ | ||
| 2886 | 8 | struct in_addr check = net.addr.in; | |
| 2887 | 8 | check.s_addr &= net.mask.in.s_addr; | |
| 2888 | |||
| 2889 | /* Check network. */ | ||
| 2890 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 6 times.
|
8 | if (check.s_addr != net.addr.in.s_addr) |
| 2891 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | sql_print_warning( |
| 2892 | "The network mask hides a part of the address for " | ||
| 2893 | "'%s/%d' in 'proxy_protocol_networks' directive.", | ||
| 2894 | buffer, bits); | ||
| 2895 | } else { | ||
| 2896 | /* Process IPv6 mask */ | ||
| 2897 | 11 | memset(&net.mask.in6, 0, sizeof(net.mask.in6)); | |
| 2898 |
4/4✓ Branch 0 taken 10 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 9 times.
|
11 | if (bits > 0 && bits < 32) { |
| 2899 | 1 | net.mask.in6.s6_addr32[0] = ~((0x80000000 >> (bits - 1)) - 1); | |
| 2900 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
|
10 | } else if (bits == 32) { |
| 2901 | 1 | net.mask.in6.s6_addr32[0] = 0xffffffff; | |
| 2902 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 6 times.
|
9 | } else if (bits > 32 && bits <= 64) { |
| 2903 | 2 | net.mask.in6.s6_addr32[0] = 0xffffffff; | |
| 2904 | 2 | net.mask.in6.s6_addr32[1] = | |
| 2905 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | (bits == 64) ? 0xffffffff : ~((0x80000000 >> (bits - 32 - 1)) - 1); |
| 2906 |
4/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 3 times.
|
7 | } else if (bits > 64 && bits <= 96) { |
| 2907 | 3 | net.mask.in6.s6_addr32[0] = 0xffffffff; | |
| 2908 | 3 | net.mask.in6.s6_addr32[1] = 0xffffffff; | |
| 2909 | 3 | net.mask.in6.s6_addr32[2] = | |
| 2910 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | (bits == 96) ? 0xffffffff : ~((0x80000000 >> (bits - 64 - 1)) - 1); |
| 2911 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
|
4 | } else if (bits > 96) { |
| 2912 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | assert(bits <= 128); |
| 2913 | 3 | net.mask.in6.s6_addr32[0] = 0xffffffff; | |
| 2914 | 3 | net.mask.in6.s6_addr32[1] = 0xffffffff; | |
| 2915 | 3 | net.mask.in6.s6_addr32[2] = 0xffffffff; | |
| 2916 | 3 | net.mask.in6.s6_addr32[3] = | |
| 2917 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | (bits == 128) ? 0xffffffff : ~((0x80000000 >> (bits - 96 - 1)) - 1); |
| 2918 | } | ||
| 2919 | |||
| 2920 | 11 | net.mask.in6.s6_addr32[0] = htonl(net.mask.in6.s6_addr32[0]); | |
| 2921 | 11 | net.mask.in6.s6_addr32[1] = htonl(net.mask.in6.s6_addr32[1]); | |
| 2922 | 11 | net.mask.in6.s6_addr32[2] = htonl(net.mask.in6.s6_addr32[2]); | |
| 2923 | 11 | net.mask.in6.s6_addr32[3] = htonl(net.mask.in6.s6_addr32[3]); | |
| 2924 | |||
| 2925 | /* Apply mask */ | ||
| 2926 | 11 | struct in6_addr check = net.addr.in6; | |
| 2927 | 11 | check.s6_addr32[0] &= net.mask.in6.s6_addr32[0]; | |
| 2928 | 11 | check.s6_addr32[1] &= net.mask.in6.s6_addr32[1]; | |
| 2929 | 11 | check.s6_addr32[2] &= net.mask.in6.s6_addr32[2]; | |
| 2930 | 11 | check.s6_addr32[3] &= net.mask.in6.s6_addr32[3]; | |
| 2931 | |||
| 2932 | /* Check network. */ | ||
| 2933 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3 times.
|
11 | if (memcmp(check.s6_addr, net.addr.in6.s6_addr, 16)) { |
| 2934 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | sql_print_warning( |
| 2935 | "The network mask hides a part of the address for " | ||
| 2936 | "'%s/%d' in 'proxy_protocol_networks' directive.", | ||
| 2937 | buffer, bits); | ||
| 2938 | } | ||
| 2939 | } | ||
| 2940 | |||
| 2941 |
4/4✓ Branch 0 taken 18 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 17 times.
|
19 | if (*p != '\0' && *p != ',') { |
| 2942 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error("Bad syntax in 'proxy_protocol_networks' directive."); |
| 2943 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | unireg_abort(1); |
| 2944 | } | ||
| 2945 | |||
| 2946 | /* add network. */ | ||
| 2947 | 18 | vio_proxy_protocol_add(net); | |
| 2948 | |||
| 2949 | /* stop the parsing. */ | ||
| 2950 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17 times.
|
18 | if (*p == '\0') break; |
| 2951 | 17 | p++; | |
| 2952 | 17 | } | |
| 2953 | } | ||
| 2954 | |||
| 2955 | 12072 | static void set_ports() { | |
| 2956 | char *env; | ||
| 2957 |
2/2✓ Branch 0 taken 429 times.
✓ Branch 1 taken 11643 times.
|
12072 | if (!mysqld_port && |
| 2958 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 345 times.
|
429 | !opt_disable_networking) { // Get port if not from commandline |
| 2959 | 84 | mysqld_port = MYSQL_PORT; | |
| 2960 | |||
| 2961 | /* | ||
| 2962 | if builder specifically requested a default port, use that | ||
| 2963 | (even if it coincides with our factory default). | ||
| 2964 | only if they didn't do we check /etc/services (and, failing | ||
| 2965 | on that, fall back to the factory default of 3306). | ||
| 2966 | either default can be overridden by the environment variable | ||
| 2967 | MYSQL_TCP_PORT, which in turn can be overridden with command | ||
| 2968 | line options. | ||
| 2969 | */ | ||
| 2970 | |||
| 2971 | #if MYSQL_PORT_DEFAULT == 0 | ||
| 2972 | struct servent *serv_ptr; | ||
| 2973 |
1/2✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
84 | if ((serv_ptr = getservbyname("mysql", "tcp"))) |
| 2974 | 84 | mysqld_port = ntohs((u_short)serv_ptr->s_port); /* purecov: inspected */ | |
| 2975 | #endif | ||
| 2976 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
|
84 | if ((env = getenv("MYSQL_TCP_PORT"))) |
| 2977 | ✗ | mysqld_port = (uint)atoi(env); /* purecov: inspected */ | |
| 2978 | } | ||
| 2979 |
2/2✓ Branch 0 taken 351 times.
✓ Branch 1 taken 11721 times.
|
12072 | if (!mysqld_unix_port) { |
| 2980 | #ifdef _WIN32 | ||
| 2981 | mysqld_unix_port = (char *)MYSQL_NAMEDPIPE; | ||
| 2982 | #else | ||
| 2983 | 351 | mysqld_unix_port = MYSQL_UNIX_ADDR; | |
| 2984 | #endif | ||
| 2985 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 351 times.
|
351 | if ((env = getenv("MYSQL_UNIX_PORT"))) |
| 2986 | ✗ | mysqld_unix_port = env; /* purecov: inspected */ | |
| 2987 | } | ||
| 2988 | 12072 | } | |
| 2989 | |||
| 2990 | #if !defined(_WIN32) | ||
| 2991 | /* Change to run as another user if started with --user */ | ||
| 2992 | |||
| 2993 | 12087 | static PasswdValue check_user(const char *user) { | |
| 2994 | 12087 | uid_t user_id = geteuid(); | |
| 2995 | |||
| 2996 | PasswdValue tmp_user_info = | ||
| 2997 |
3/4✓ Branch 0 taken 12069 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
12087 | (user == nullptr ? PasswdValue{} : my_getpwnam(user)); |
| 2998 | |||
| 2999 | // Don't bother if we aren't superuser | ||
| 3000 |
1/2✓ Branch 0 taken 12087 times.
✗ Branch 1 not taken.
|
12087 | if (user_id) { |
| 3001 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 12069 times.
|
12087 | if (user) { |
| 3002 | /* Don't give a warning, if real user is same as given with --user */ | ||
| 3003 |
4/6✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
|
18 | if ((tmp_user_info.IsVoid() || user_id != tmp_user_info.pw_uid)) |
| 3004 |
8/16✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18 times.
✗ Branch 15 not taken.
|
18 | LogErr(WARNING_LEVEL, ER_USER_REQUIRES_ROOT); |
| 3005 | } | ||
| 3006 | 12087 | return PasswdValue{}; | |
| 3007 | } | ||
| 3008 | ✗ | assert(user_id == 0); // we are running as root | |
| 3009 | |||
| 3010 | ✗ | if (!user) { | |
| 3011 | ✗ | if (!opt_initialize && !is_help_or_validate_option()) { | |
| 3012 | ✗ | LogErr(ERROR_LEVEL, ER_REALLY_RUN_AS_ROOT); | |
| 3013 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3014 | } | ||
| 3015 | ✗ | return PasswdValue{}; | |
| 3016 | } | ||
| 3017 | /* purecov: begin tested */ | ||
| 3018 | ✗ | if (!strcmp(user, "root")) | |
| 3019 | ✗ | return PasswdValue{}; // Avoid problem with dynamic libraries | |
| 3020 | |||
| 3021 | ✗ | if (tmp_user_info.IsVoid()) { | |
| 3022 | // Allow a numeric uid to be used | ||
| 3023 | const char *pos; | ||
| 3024 | ✗ | for (pos = user; my_isdigit(mysqld_charset, *pos); pos++) | |
| 3025 | ; | ||
| 3026 | ✗ | if (*pos) // Not numeric id | |
| 3027 | ✗ | goto err; | |
| 3028 | |||
| 3029 | ✗ | tmp_user_info = my_getpwuid(atoi(user)); | |
| 3030 | ✗ | if (tmp_user_info.IsVoid()) goto err; | |
| 3031 | } | ||
| 3032 | ✗ | return tmp_user_info; | |
| 3033 | /* purecov: end */ | ||
| 3034 | |||
| 3035 | ✗ | err: | |
| 3036 | ✗ | LogErr(ERROR_LEVEL, ER_USER_WHAT_USER, user); | |
| 3037 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3038 | |||
| 3039 | ✗ | return PasswdValue{}; | |
| 3040 | 12087 | } | |
| 3041 | |||
| 3042 | namespace mysqld_funcs_unit_test { | ||
| 3043 | 21 | PasswdValue check_user_drv(const char *user) { return check_user(user); } | |
| 3044 | } // namespace mysqld_funcs_unit_test | ||
| 3045 | |||
| 3046 | ✗ | static void set_user(const char *user, const PasswdValue &user_info_arg) { | |
| 3047 | /* purecov: begin tested */ | ||
| 3048 | ✗ | assert(user_info_arg.IsVoid() == false); | |
| 3049 | #ifdef HAVE_INITGROUPS | ||
| 3050 | ✗ | initgroups(user, user_info_arg.pw_gid); | |
| 3051 | #endif | ||
| 3052 | ✗ | if (setgid(user_info_arg.pw_gid) == -1) { | |
| 3053 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_SETGID, strerror(errno)); | |
| 3054 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3055 | } | ||
| 3056 | ✗ | if (setuid(user_info_arg.pw_uid) == -1) { | |
| 3057 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_SETUID, strerror(errno)); | |
| 3058 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3059 | } | ||
| 3060 | |||
| 3061 | #ifdef HAVE_SYS_PRCTL_H | ||
| 3062 | ✗ | if (test_flags & TEST_CORE_ON_SIGNAL) { | |
| 3063 | /* inform kernel that process is dumpable */ | ||
| 3064 | ✗ | (void)prctl(PR_SET_DUMPABLE, 1); | |
| 3065 | } | ||
| 3066 | #endif | ||
| 3067 | |||
| 3068 | /* purecov: end */ | ||
| 3069 | } | ||
| 3070 | |||
| 3071 | ✗ | static void set_effective_user(const PasswdValue &user_info_arg) { | |
| 3072 | ✗ | assert(user_info_arg.IsVoid() == false); | |
| 3073 | ✗ | if (setregid((gid_t)-1, user_info_arg.pw_gid) == -1) { | |
| 3074 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_SETREGID, strerror(errno)); | |
| 3075 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3076 | } | ||
| 3077 | ✗ | if (setreuid((uid_t)-1, user_info_arg.pw_uid) == -1) { | |
| 3078 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_SETREUID, strerror(errno)); | |
| 3079 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3080 | } | ||
| 3081 | } | ||
| 3082 | |||
| 3083 | /** Change root user if started with @c --chroot . */ | ||
| 3084 | ✗ | static void set_root(const char *path) { | |
| 3085 | ✗ | if (chroot(path) == -1) { | |
| 3086 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_CHROOT, strerror(errno)); | |
| 3087 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 3088 | } | ||
| 3089 | ✗ | my_setwd("/", MYF(0)); | |
| 3090 | } | ||
| 3091 | #endif // !_WIN32 | ||
| 3092 | |||
| 3093 | /** | ||
| 3094 | Check that an address value is a wildcard IP value, | ||
| 3095 | that is it has either the value 0.0.0.0 for IPv4 or the value ::1 in | ||
| 3096 | case IPv6, or has the specially treated symbol * as its value. | ||
| 3097 | |||
| 3098 | @param address_value Address value to check | ||
| 3099 | @param address_length Address length | ||
| 3100 | |||
| 3101 | @return true in case the address value is a wildcard value, else false. | ||
| 3102 | */ | ||
| 3103 | 11589 | bool check_address_is_wildcard(const char *address_value, | |
| 3104 | size_t address_length) { | ||
| 3105 | return | ||
| 3106 | // Wildcard is not allowed in case a comma separated list of | ||
| 3107 | // addresses is specified | ||
| 3108 | 11589 | native_strncasecmp(address_value, MY_BIND_ALL_ADDRESSES, | |
| 3109 |
2/2✓ Branch 0 taken 73 times.
✓ Branch 1 taken 6 times.
|
79 | address_length) == 0 || |
| 3110 | // The specially treated address :: is not allowed in case | ||
| 3111 | // a comma separated list of addresses is specified | ||
| 3112 | 79 | native_strncasecmp(address_value, ipv6_all_addresses, address_length) == | |
| 3113 |
4/4✓ Branch 0 taken 79 times.
✓ Branch 1 taken 11510 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 68 times.
|
11668 | 0 || |
| 3114 | // The specially treated address 0.0.0.0 is not allowed in case | ||
| 3115 | // a comma separated list of addresses is specified | ||
| 3116 | 73 | native_strncasecmp(address_value, ipv4_all_addresses, address_length) == | |
| 3117 | 11589 | 0; | |
| 3118 | } | ||
| 3119 | |||
| 3120 | /** | ||
| 3121 | Take a string representing host or ip address followed by | ||
| 3122 | optional delimiter '/' and namespace name and put address part | ||
| 3123 | and namespace part into corresponding output parameters. | ||
| 3124 | |||
| 3125 | @param begin_address_value start of a string containing an address value | ||
| 3126 | @param end_address_value pointer to an end of string containing | ||
| 3127 | an address value. Has the value nullptr in case | ||
| 3128 | address value not continue | ||
| 3129 | @param [out] address_value address value extracted from address string | ||
| 3130 | @param [out] network_namespace network namespace extracted from | ||
| 3131 | the address string value if any | ||
| 3132 | |||
| 3133 | @return false on success, true on address format error | ||
| 3134 | */ | ||
| 3135 | 11491 | static bool parse_address_string(const char *begin_address_value, | |
| 3136 | const char *end_address_value, | ||
| 3137 | std::string *address_value, | ||
| 3138 | std::string *network_namespace) { | ||
| 3139 | 11491 | const char *namespace_separator = strchr(begin_address_value, '/'); | |
| 3140 | |||
| 3141 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11491 times.
|
11491 | if (namespace_separator != nullptr) { |
| 3142 | ✗ | if (begin_address_value == namespace_separator) | |
| 3143 | /* | ||
| 3144 | Parse error: there is no character before '/', | ||
| 3145 | that is missed address value | ||
| 3146 | */ | ||
| 3147 | ✗ | return true; | |
| 3148 | |||
| 3149 | ✗ | if (namespace_separator < end_address_value) { | |
| 3150 | ✗ | if (end_address_value - namespace_separator == 1) | |
| 3151 | /* | ||
| 3152 | Parse error: there is no character immediately after '/', | ||
| 3153 | that is missed namespace name. | ||
| 3154 | */ | ||
| 3155 | ✗ | return true; | |
| 3156 | |||
| 3157 | /* | ||
| 3158 | Found namespace delimiter. Extract namespace and address values | ||
| 3159 | */ | ||
| 3160 | ✗ | *address_value = std::string(begin_address_value, namespace_separator); | |
| 3161 | *network_namespace = | ||
| 3162 | ✗ | std::string(namespace_separator + 1, end_address_value); | |
| 3163 | ✗ | } else if (end_address_value != nullptr) | |
| 3164 | /* | ||
| 3165 | This branch corresponds to the case when namespace separator is located | ||
| 3166 | after the last character of the address subvalue being processed. | ||
| 3167 | For example, if the following string '192.168.1.1,172.1.1.1/red' | ||
| 3168 | passed into the function create_bind_address_info_from_string(), | ||
| 3169 | then during handling of the address 192.168.1.1 search of '/' | ||
| 3170 | will return a position after the end of the sub string 192.168.1.1 | ||
| 3171 | (in the next sub string 172.1.1.1/red) that should be ignored. | ||
| 3172 | */ | ||
| 3173 | ✗ | *address_value = std::string(begin_address_value, end_address_value); | |
| 3174 | else { | ||
| 3175 | /* | ||
| 3176 | This branch corresponds to the case when namespace separator is located | ||
| 3177 | at the last part of address values. For example, | ||
| 3178 | this branch is executed during handling of the following value | ||
| 3179 | 192.168.1.1,::1,::1/greeen for the option --bind-address. | ||
| 3180 | */ | ||
| 3181 | ✗ | *address_value = std::string(begin_address_value, namespace_separator); | |
| 3182 | ✗ | *network_namespace = std::string(namespace_separator + 1); | |
| 3183 | ✗ | if (*(namespace_separator + 1) == 0) | |
| 3184 | /* | ||
| 3185 | Parse error: there is no character immediately | ||
| 3186 | after '/' - a namespace name missed. | ||
| 3187 | */ | ||
| 3188 | ✗ | return true; | |
| 3189 | } | ||
| 3190 | } else { | ||
| 3191 | /* | ||
| 3192 | Regular address without network namespace found. | ||
| 3193 | */ | ||
| 3194 | *address_value = end_address_value != nullptr | ||
| 3195 |
8/14✓ Branch 0 taken 9 times.
✓ Branch 1 taken 11482 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11482 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11482 times.
✓ Branch 7 taken 9 times.
✓ Branch 8 taken 9 times.
✓ Branch 9 taken 11482 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
|
22982 | ? std::string(begin_address_value, end_address_value) |
| 3196 | 11491 | : std::string(begin_address_value); | |
| 3197 | } | ||
| 3198 | |||
| 3199 | 11491 | return false; | |
| 3200 | } | ||
| 3201 | |||
| 3202 | /** | ||
| 3203 | Parse a value of address sub string with checking of address string format, | ||
| 3204 | extract address part and namespace part of the address value, and store | ||
| 3205 | their values into the argument valid_bind_addresses. | ||
| 3206 | |||
| 3207 | @return false on success, true on address format error | ||
| 3208 | */ | ||
| 3209 | 11459 | static bool create_bind_address_info_from_string( | |
| 3210 | const char *begin_address_value, const char *end_address_value, | ||
| 3211 | std::list<Bind_address_info> *valid_bind_addresses) { | ||
| 3212 | 11459 | Bind_address_info bind_address_info; | |
| 3213 | 11459 | std::string address_value, network_namespace; | |
| 3214 | |||
| 3215 |
2/4✓ Branch 0 taken 11459 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11459 times.
|
11459 | if (parse_address_string(begin_address_value, end_address_value, |
| 3216 | &address_value, &network_namespace)) | ||
| 3217 | ✗ | return true; | |
| 3218 | |||
| 3219 |
1/2✓ Branch 0 taken 11459 times.
✗ Branch 1 not taken.
|
11459 | if (network_namespace.empty()) |
| 3220 |
1/2✓ Branch 0 taken 11459 times.
✗ Branch 1 not taken.
|
11459 | bind_address_info = Bind_address_info(address_value); |
| 3221 | else { | ||
| 3222 | /* | ||
| 3223 | Wildcard value is not allowed in case network namespace specified | ||
| 3224 | for address value in the option bind-address. | ||
| 3225 | */ | ||
| 3226 | ✗ | if (check_address_is_wildcard(address_value.c_str(), | |
| 3227 | address_value.length())) { | ||
| 3228 | ✗ | LogErr(ERROR_LEVEL, | |
| 3229 | ER_NETWORK_NAMESPACE_NOT_ALLOWED_FOR_WILDCARD_ADDRESS); | ||
| 3230 | ✗ | return true; | |
| 3231 | } | ||
| 3232 | |||
| 3233 | ✗ | bind_address_info = Bind_address_info(address_value, network_namespace); | |
| 3234 | } | ||
| 3235 | |||
| 3236 |
1/2✓ Branch 0 taken 11459 times.
✗ Branch 1 not taken.
|
11459 | valid_bind_addresses->emplace_back(bind_address_info); |
| 3237 | |||
| 3238 | 11459 | return false; | |
| 3239 | 11459 | } | |
| 3240 | |||
| 3241 | /** | ||
| 3242 | Check acceptable value(s) of parameter bind-address | ||
| 3243 | |||
| 3244 | @param bind_address Value of the parameter bind-address | ||
| 3245 | @param[out] valid_bind_addresses List of addresses to listen and their | ||
| 3246 | corresponding network namespaces if set. | ||
| 3247 | |||
| 3248 | @return false on success, true on failure | ||
| 3249 | */ | ||
| 3250 | 11458 | static bool check_bind_address_has_valid_value( | |
| 3251 | const char *bind_address, | ||
| 3252 | std::list<Bind_address_info> *valid_bind_addresses) { | ||
| 3253 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11456 times.
|
11458 | if (strlen(bind_address) == 0) |
| 3254 | // Empty value for bind_address is an error | ||
| 3255 | 2 | return true; | |
| 3256 | |||
| 3257 | 11456 | const char *comma_separator = strchr(bind_address, ','); | |
| 3258 | 11456 | const char *begin_of_value = bind_address; | |
| 3259 | 11456 | const bool multiple_bind_addresses = (comma_separator != nullptr); | |
| 3260 | |||
| 3261 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11455 times.
|
11456 | if (comma_separator == begin_of_value) |
| 3262 | // Return an error if a value of bind_address begins with comma | ||
| 3263 | 1 | return true; | |
| 3264 | |||
| 3265 |
2/2✓ Branch 0 taken 10 times.
✓ Branch 1 taken 11453 times.
|
11463 | while (comma_separator != nullptr) { |
| 3266 | 10 | Bind_address_info bind_address_info; | |
| 3267 | 10 | std::string address_value, network_namespace; | |
| 3268 | /* | ||
| 3269 | Wildcard value is not allowed in case multi-addresses value specified | ||
| 3270 | for the option bind-address. | ||
| 3271 | */ | ||
| 3272 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
|
10 | if (check_address_is_wildcard(begin_of_value, |
| 3273 |
1/2✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
|
10 | comma_separator - begin_of_value)) { |
| 3274 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(ERROR_LEVEL, ER_WILDCARD_NOT_ALLOWED_FOR_MULTIADDRESS_BIND); |
| 3275 | |||
| 3276 | 1 | return true; | |
| 3277 | } | ||
| 3278 | |||
| 3279 |
2/4✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
|
9 | if (create_bind_address_info_from_string(begin_of_value, comma_separator, |
| 3280 | valid_bind_addresses)) | ||
| 3281 | ✗ | return true; | |
| 3282 | |||
| 3283 | 9 | begin_of_value = comma_separator + 1; | |
| 3284 | 9 | comma_separator = strchr(begin_of_value, ','); | |
| 3285 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
|
9 | if (comma_separator == begin_of_value) |
| 3286 | // Return an error if a value of bind_address has two adjacent commas | ||
| 3287 | 1 | return true; | |
| 3288 |
6/6✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 2 times.
|
14 | } |
| 3289 | |||
| 3290 | /* | ||
| 3291 | Wildcard value is not allowed in case multi-addresses value specified | ||
| 3292 | for the option bind-address. | ||
| 3293 | */ | ||
| 3294 |
4/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11448 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 11450 times.
|
11458 | if (multiple_bind_addresses && |
| 3295 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | (check_address_is_wildcard(begin_of_value, strlen(begin_of_value)) || |
| 3296 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | strlen(begin_of_value) == 0)) |
| 3297 | 3 | return true; | |
| 3298 | |||
| 3299 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11450 times.
|
11450 | if (create_bind_address_info_from_string(begin_of_value, comma_separator, |
| 3300 | valid_bind_addresses)) | ||
| 3301 | ✗ | return true; | |
| 3302 | |||
| 3303 | 11450 | return false; | |
| 3304 | } | ||
| 3305 | |||
| 3306 | /** | ||
| 3307 | Check acceptable value(s) of the parameter admin-address | ||
| 3308 | |||
| 3309 | @param admin_bind_addr_str Value of the parameter admin-address | ||
| 3310 | @param[out] admin_address_info List of addresses to listen and their | ||
| 3311 | corresponding network namespaces if set. | ||
| 3312 | |||
| 3313 | @return false on success, true on failure | ||
| 3314 | */ | ||
| 3315 | 32 | static bool check_admin_address_has_valid_value( | |
| 3316 | const char *admin_bind_addr_str, Bind_address_info *admin_address_info) { | ||
| 3317 | 32 | std::string address_value, network_namespace; | |
| 3318 | |||
| 3319 |
2/4✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
|
32 | if (parse_address_string(admin_bind_addr_str, nullptr, &address_value, |
| 3320 | &network_namespace)) | ||
| 3321 | ✗ | return true; | |
| 3322 | |||
| 3323 |
3/4✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 29 times.
|
32 | if (check_address_is_wildcard(address_value.c_str(), |
| 3324 | address_value.length())) { | ||
| 3325 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | if (!network_namespace.empty()) |
| 3326 | ✗ | LogErr(ERROR_LEVEL, | |
| 3327 | ER_NETWORK_NAMESPACE_NOT_ALLOWED_FOR_WILDCARD_ADDRESS); | ||
| 3328 | |||
| 3329 | 3 | return true; | |
| 3330 | } | ||
| 3331 | |||
| 3332 |
1/2✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
|
29 | if (network_namespace.empty()) |
| 3333 |
1/2✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
|
29 | *admin_address_info = Bind_address_info(address_value); |
| 3334 | else | ||
| 3335 | ✗ | *admin_address_info = Bind_address_info(address_value, network_namespace); | |
| 3336 | |||
| 3337 | 29 | return false; | |
| 3338 | 32 | } | |
| 3339 | |||
| 3340 | 11758 | static bool network_init(void) { | |
| 3341 |
2/2✓ Branch 0 taken 290 times.
✓ Branch 1 taken 11468 times.
|
11758 | if (opt_initialize) return false; |
| 3342 | |||
| 3343 |
1/2✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
|
11468 | set_proxy(); |
| 3344 | #ifdef HAVE_SYS_UN_H | ||
| 3345 |
2/4✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11458 times.
✗ Branch 3 not taken.
|
11458 | std::string const unix_sock_name(mysqld_unix_port ? mysqld_unix_port : ""); |
| 3346 | #else | ||
| 3347 | std::string const unix_sock_name(""); | ||
| 3348 | #endif | ||
| 3349 | |||
| 3350 | 11458 | std::list<Bind_address_info> bind_addresses_info; | |
| 3351 | |||
| 3352 |
5/8✓ Branch 0 taken 27 times.
✓ Branch 1 taken 11431 times.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11458 times.
✗ Branch 7 not taken.
|
11458 | if (!opt_disable_networking || unix_sock_name != "") { |
| 3353 |
3/4✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 11450 times.
|
22916 | if (my_bind_addr_str != nullptr && |
| 3354 |
3/4✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 11450 times.
|
11458 | check_bind_address_has_valid_value(my_bind_addr_str, |
| 3355 | &bind_addresses_info)) { | ||
| 3356 |
8/16✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
|
8 | LogErr(ERROR_LEVEL, ER_INVALID_VALUE_OF_BIND_ADDRESSES, my_bind_addr_str); |
| 3357 | 15 | return true; | |
| 3358 | } | ||
| 3359 | |||
| 3360 | 11450 | Bind_address_info admin_address_info; | |
| 3361 |
2/2✓ Branch 0 taken 11423 times.
✓ Branch 1 taken 27 times.
|
11450 | if (!opt_disable_networking) { |
| 3362 |
4/4✓ Branch 0 taken 32 times.
✓ Branch 1 taken 11391 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 11420 times.
|
11455 | if (my_admin_bind_addr_str != nullptr && |
| 3363 |
3/4✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 29 times.
|
32 | check_admin_address_has_valid_value(my_admin_bind_addr_str, |
| 3364 | &admin_address_info)) { | ||
| 3365 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | LogErr(ERROR_LEVEL, ER_INVALID_ADMIN_ADDRESS, my_admin_bind_addr_str); |
| 3366 | 3 | return true; | |
| 3367 | } | ||
| 3368 | /* | ||
| 3369 | Port 0 is interpreted by implementations of TCP protocol | ||
| 3370 | as a hint to find a first free port value to use and bind to it. | ||
| 3371 | On the other hand, the option mysqld_admin_port can be assigned | ||
| 3372 | the value 0 if a user specified a value that is out of allowable | ||
| 3373 | range of values. Therefore, to avoid a case when an operating | ||
| 3374 | system binds admin interface to am arbitrary selected port value, | ||
| 3375 | set it explicitly to the value MYSQL_ADMIN_PORT in case it has value 0. | ||
| 3376 | */ | ||
| 3377 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11419 times.
|
11420 | if (mysqld_admin_port == 0) mysqld_admin_port = MYSQL_ADMIN_PORT; |
| 3378 | } | ||
| 3379 | Mysqld_socket_listener *mysqld_socket_listener = new (std::nothrow) | ||
| 3380 | Mysqld_socket_listener(bind_addresses_info, mysqld_port, | ||
| 3381 | admin_address_info, mysqld_admin_port, | ||
| 3382 | 11447 | admin_address_info.address.empty() | |
| 3383 |
2/2✓ Branch 0 taken 11418 times.
✓ Branch 1 taken 29 times.
|
11447 | ? false |
| 3384 | : listen_admin_interface_in_separate_thread, | ||
| 3385 |
3/6✓ Branch 0 taken 11447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11447 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11447 times.
✗ Branch 5 not taken.
|
11447 | back_log, mysqld_port_timeout, unix_sock_name); |
| 3386 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11447 times.
|
11447 | if (mysqld_socket_listener == nullptr) return true; |
| 3387 | |||
| 3388 | 11447 | mysqld_socket_acceptor = new (std::nothrow) | |
| 3389 |
1/2✓ Branch 0 taken 11447 times.
✗ Branch 1 not taken.
|
11447 | Connection_acceptor<Mysqld_socket_listener>(mysqld_socket_listener); |
| 3390 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11447 times.
|
11447 | if (mysqld_socket_acceptor == nullptr) { |
| 3391 | ✗ | delete mysqld_socket_listener; | |
| 3392 | ✗ | mysqld_socket_listener = nullptr; | |
| 3393 | ✗ | return true; | |
| 3394 | } | ||
| 3395 | |||
| 3396 |
3/4✓ Branch 0 taken 11447 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 11443 times.
|
11447 | if (mysqld_socket_acceptor->init_connection_acceptor()) |
| 3397 | 4 | return true; // mysqld_socket_acceptor would be freed in unireg_abort. | |
| 3398 | |||
| 3399 |
2/2✓ Branch 0 taken 8682 times.
✓ Branch 1 taken 2761 times.
|
11443 | if (report_port == 0) report_port = mysqld_port; |
| 3400 | |||
| 3401 |
3/4✓ Branch 0 taken 11416 times.
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11416 times.
|
11443 | if (!opt_disable_networking) assert(report_port != 0); |
| 3402 |
2/2✓ Branch 0 taken 11443 times.
✓ Branch 1 taken 7 times.
|
11450 | } |
| 3403 | #ifdef _WIN32 | ||
| 3404 | // Create named pipe | ||
| 3405 | if (opt_enable_named_pipe) { | ||
| 3406 | std::string pipe_name = mysqld_unix_port ? mysqld_unix_port : ""; | ||
| 3407 | |||
| 3408 | named_pipe_listener = new (std::nothrow) Named_pipe_listener(&pipe_name); | ||
| 3409 | if (named_pipe_listener == NULL) return true; | ||
| 3410 | |||
| 3411 | named_pipe_acceptor = new (std::nothrow) | ||
| 3412 | Connection_acceptor<Named_pipe_listener>(named_pipe_listener); | ||
| 3413 | if (named_pipe_acceptor == NULL) { | ||
| 3414 | delete named_pipe_listener; | ||
| 3415 | named_pipe_listener = NULL; | ||
| 3416 | return true; | ||
| 3417 | } | ||
| 3418 | |||
| 3419 | if (named_pipe_acceptor->init_connection_acceptor()) | ||
| 3420 | return true; // named_pipe_acceptor would be freed in unireg_abort. | ||
| 3421 | } | ||
| 3422 | |||
| 3423 | // Setup shared_memory acceptor | ||
| 3424 | if (opt_enable_shared_memory) { | ||
| 3425 | std::string shared_mem_base_name = | ||
| 3426 | shared_memory_base_name ? shared_memory_base_name : ""; | ||
| 3427 | |||
| 3428 | Shared_mem_listener *shared_mem_listener = | ||
| 3429 | new (std::nothrow) Shared_mem_listener(&shared_mem_base_name); | ||
| 3430 | if (shared_mem_listener == NULL) return true; | ||
| 3431 | |||
| 3432 | shared_mem_acceptor = new (std::nothrow) | ||
| 3433 | Connection_acceptor<Shared_mem_listener>(shared_mem_listener); | ||
| 3434 | if (shared_mem_acceptor == NULL) { | ||
| 3435 | delete shared_mem_listener; | ||
| 3436 | shared_mem_listener = NULL; | ||
| 3437 | return true; | ||
| 3438 | } | ||
| 3439 | |||
| 3440 | if (shared_mem_acceptor->init_connection_acceptor()) | ||
| 3441 | return true; // shared_mem_acceptor would be freed in unireg_abort. | ||
| 3442 | } | ||
| 3443 | #endif // _WIN32 | ||
| 3444 | 11443 | return false; | |
| 3445 | 11458 | } | |
| 3446 | |||
| 3447 | #ifdef _WIN32 | ||
| 3448 | static uint handler_count = 0; | ||
| 3449 | |||
| 3450 | static inline void decrement_handler_count() { | ||
| 3451 | mysql_mutex_lock(&LOCK_handler_count); | ||
| 3452 | handler_count--; | ||
| 3453 | mysql_cond_signal(&COND_handler_count); | ||
| 3454 | mysql_mutex_unlock(&LOCK_handler_count); | ||
| 3455 | } | ||
| 3456 | |||
| 3457 | extern "C" void *socket_conn_event_handler(void *arg) { | ||
| 3458 | my_thread_init(); | ||
| 3459 | |||
| 3460 | Connection_acceptor<Mysqld_socket_listener> *conn_acceptor = | ||
| 3461 | static_cast<Connection_acceptor<Mysqld_socket_listener> *>(arg); | ||
| 3462 | conn_acceptor->connection_event_loop(); | ||
| 3463 | |||
| 3464 | decrement_handler_count(); | ||
| 3465 | my_thread_end(); | ||
| 3466 | return 0; | ||
| 3467 | } | ||
| 3468 | |||
| 3469 | extern "C" void *named_pipe_conn_event_handler(void *arg) { | ||
| 3470 | my_thread_init(); | ||
| 3471 | |||
| 3472 | Connection_acceptor<Named_pipe_listener> *conn_acceptor = | ||
| 3473 | static_cast<Connection_acceptor<Named_pipe_listener> *>(arg); | ||
| 3474 | conn_acceptor->connection_event_loop(); | ||
| 3475 | |||
| 3476 | decrement_handler_count(); | ||
| 3477 | my_thread_end(); | ||
| 3478 | return 0; | ||
| 3479 | } | ||
| 3480 | |||
| 3481 | extern "C" void *shared_mem_conn_event_handler(void *arg) { | ||
| 3482 | my_thread_init(); | ||
| 3483 | |||
| 3484 | Connection_acceptor<Shared_mem_listener> *conn_acceptor = | ||
| 3485 | static_cast<Connection_acceptor<Shared_mem_listener> *>(arg); | ||
| 3486 | conn_acceptor->connection_event_loop(); | ||
| 3487 | |||
| 3488 | decrement_handler_count(); | ||
| 3489 | my_thread_end(); | ||
| 3490 | return 0; | ||
| 3491 | } | ||
| 3492 | |||
| 3493 | void setup_conn_event_handler_threads() { | ||
| 3494 | my_thread_handle hThread; | ||
| 3495 | |||
| 3496 | DBUG_TRACE; | ||
| 3497 | |||
| 3498 | if ((!have_tcpip || opt_disable_networking) && !opt_enable_shared_memory && | ||
| 3499 | !opt_enable_named_pipe) { | ||
| 3500 | LogErr(ERROR_LEVEL, ER_WIN_LISTEN_BUT_HOW); | ||
| 3501 | unireg_abort(MYSQLD_ABORT_EXIT); // Will not return | ||
| 3502 | } | ||
| 3503 | |||
| 3504 | mysql_mutex_lock(&LOCK_handler_count); | ||
| 3505 | handler_count = 0; | ||
| 3506 | |||
| 3507 | if (opt_enable_named_pipe) { | ||
| 3508 | int error = mysql_thread_create( | ||
| 3509 | key_thread_handle_con_namedpipes, &hThread, &connection_attrib, | ||
| 3510 | named_pipe_conn_event_handler, named_pipe_acceptor); | ||
| 3511 | if (!error) | ||
| 3512 | handler_count++; | ||
| 3513 | else | ||
| 3514 | LogErr(WARNING_LEVEL, ER_CANT_CREATE_NAMED_PIPES_THREAD, error); | ||
| 3515 | } | ||
| 3516 | |||
| 3517 | if (have_tcpip && !opt_disable_networking) { | ||
| 3518 | int error = mysql_thread_create( | ||
| 3519 | key_thread_handle_con_sockets, &hThread, &connection_attrib, | ||
| 3520 | socket_conn_event_handler, mysqld_socket_acceptor); | ||
| 3521 | if (!error) | ||
| 3522 | handler_count++; | ||
| 3523 | else | ||
| 3524 | LogErr(WARNING_LEVEL, ER_CANT_CREATE_TCPIP_THREAD, error); | ||
| 3525 | } | ||
| 3526 | |||
| 3527 | if (opt_enable_shared_memory) { | ||
| 3528 | int error = mysql_thread_create( | ||
| 3529 | key_thread_handle_con_sharedmem, &hThread, &connection_attrib, | ||
| 3530 | shared_mem_conn_event_handler, shared_mem_acceptor); | ||
| 3531 | if (!error) | ||
| 3532 | handler_count++; | ||
| 3533 | else | ||
| 3534 | LogErr(WARNING_LEVEL, ER_CANT_CREATE_SHM_THREAD, error); | ||
| 3535 | } | ||
| 3536 | |||
| 3537 | // Block until all connection listener threads have exited. | ||
| 3538 | while (handler_count > 0) | ||
| 3539 | mysql_cond_wait(&COND_handler_count, &LOCK_handler_count); | ||
| 3540 | mysql_mutex_unlock(&LOCK_handler_count); | ||
| 3541 | } | ||
| 3542 | |||
| 3543 | /* | ||
| 3544 | On Windows, we use native SetConsoleCtrlHandler for handle events like Ctrl-C | ||
| 3545 | with graceful shutdown. | ||
| 3546 | Also, we do not use signal(), but SetUnhandledExceptionFilter instead - as it | ||
| 3547 | provides possibility to pass the exception to just-in-time debugger, collect | ||
| 3548 | dumps and potentially also the exception and thread context used to output | ||
| 3549 | callstack. | ||
| 3550 | */ | ||
| 3551 | |||
| 3552 | static BOOL WINAPI console_event_handler(DWORD type) { | ||
| 3553 | DBUG_TRACE; | ||
| 3554 | if (type == CTRL_C_EVENT) { | ||
| 3555 | /* | ||
| 3556 | Do not shutdown before startup is finished and shutdown | ||
| 3557 | thread is initialized. Otherwise there is a race condition | ||
| 3558 | between main thread doing initialization and CTRL-C thread doing | ||
| 3559 | cleanup, which can result into crash. | ||
| 3560 | */ | ||
| 3561 | if (hEventShutdown) | ||
| 3562 | kill_mysql(); | ||
| 3563 | else | ||
| 3564 | LogErr(WARNING_LEVEL, ER_NOT_RIGHT_NOW); | ||
| 3565 | return true; | ||
| 3566 | } | ||
| 3567 | return false; | ||
| 3568 | } | ||
| 3569 | |||
| 3570 | #ifdef DEBUG_UNHANDLED_EXCEPTION_FILTER | ||
| 3571 | #define DEBUGGER_ATTACH_TIMEOUT 120 | ||
| 3572 | /* | ||
| 3573 | Wait for debugger to attach and break into debugger. If debugger is not | ||
| 3574 | attached, resume after timeout. | ||
| 3575 | */ | ||
| 3576 | static void wait_for_debugger(int timeout_sec) { | ||
| 3577 | if (!IsDebuggerPresent()) { | ||
| 3578 | int i; | ||
| 3579 | printf("Waiting for debugger to attach, pid=%u\n", GetCurrentProcessId()); | ||
| 3580 | fflush(stdout); | ||
| 3581 | for (i = 0; i < timeout_sec; i++) { | ||
| 3582 | Sleep(1000); | ||
| 3583 | if (IsDebuggerPresent()) { | ||
| 3584 | /* Break into debugger */ | ||
| 3585 | __debugbreak(); | ||
| 3586 | return; | ||
| 3587 | } | ||
| 3588 | } | ||
| 3589 | printf("pid=%u, debugger not attached after %d seconds, resuming\n", | ||
| 3590 | GetCurrentProcessId(), timeout_sec); | ||
| 3591 | fflush(stdout); | ||
| 3592 | } | ||
| 3593 | } | ||
| 3594 | #endif /* DEBUG_UNHANDLED_EXCEPTION_FILTER */ | ||
| 3595 | |||
| 3596 | LONG WINAPI my_unhandler_exception_filter(EXCEPTION_POINTERS *ex_pointers) { | ||
| 3597 | static BOOL first_time = true; | ||
| 3598 | if (!first_time) { | ||
| 3599 | /* | ||
| 3600 | This routine can be called twice, typically | ||
| 3601 | when detaching in JIT debugger. | ||
| 3602 | Return EXCEPTION_EXECUTE_HANDLER to terminate process. | ||
| 3603 | */ | ||
| 3604 | return EXCEPTION_EXECUTE_HANDLER; | ||
| 3605 | } | ||
| 3606 | first_time = false; | ||
| 3607 | #ifdef DEBUG_UNHANDLED_EXCEPTION_FILTER | ||
| 3608 | /* | ||
| 3609 | Unfortunately there is no clean way to debug unhandled exception filters, | ||
| 3610 | as debugger does not stop there(also documented in MSDN) | ||
| 3611 | To overcome, one could put a MessageBox, but this will not work in service. | ||
| 3612 | Better solution is to print error message and sleep some minutes | ||
| 3613 | until debugger is attached | ||
| 3614 | */ | ||
| 3615 | wait_for_debugger(DEBUGGER_ATTACH_TIMEOUT); | ||
| 3616 | #endif /* DEBUG_UNHANDLED_EXCEPTION_FILTER */ | ||
| 3617 | __try { | ||
| 3618 | my_set_exception_pointers(ex_pointers); | ||
| 3619 | handle_fatal_signal(ex_pointers->ExceptionRecord->ExceptionCode); | ||
| 3620 | } __except (EXCEPTION_EXECUTE_HANDLER) { | ||
| 3621 | DWORD written; | ||
| 3622 | const char msg[] = "Got exception in exception handler!\n"; | ||
| 3623 | WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msg, sizeof(msg) - 1, &written, | ||
| 3624 | NULL); | ||
| 3625 | } | ||
| 3626 | /* | ||
| 3627 | Return EXCEPTION_CONTINUE_SEARCH to give JIT debugger | ||
| 3628 | (drwtsn32 or vsjitdebugger) possibility to attach, | ||
| 3629 | if JIT debugger is configured. | ||
| 3630 | Windows Error reporting might generate a dump here. | ||
| 3631 | */ | ||
| 3632 | return EXCEPTION_CONTINUE_SEARCH; | ||
| 3633 | } | ||
| 3634 | |||
| 3635 | void my_init_signals() { | ||
| 3636 | if (opt_console) SetConsoleCtrlHandler(console_event_handler, true); | ||
| 3637 | |||
| 3638 | /* Avoid MessageBox()es*/ | ||
| 3639 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | ||
| 3640 | _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); | ||
| 3641 | _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); | ||
| 3642 | _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); | ||
| 3643 | _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); | ||
| 3644 | _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); | ||
| 3645 | |||
| 3646 | /* | ||
| 3647 | Do not use SEM_NOGPFAULTERRORBOX in the following SetErrorMode (), | ||
| 3648 | because it would prevent JIT debugger and Windows error reporting | ||
| 3649 | from working. We need WER or JIT-debugging, since our own unhandled | ||
| 3650 | exception filter is not guaranteed to work in all situation | ||
| 3651 | (like heap corruption or stack overflow) | ||
| 3652 | */ | ||
| 3653 | SetErrorMode(SetErrorMode(0) | SEM_FAILCRITICALERRORS | | ||
| 3654 | SEM_NOOPENFILEERRORBOX); | ||
| 3655 | SetUnhandledExceptionFilter(my_unhandler_exception_filter); | ||
| 3656 | } | ||
| 3657 | |||
| 3658 | #else // !_WIN32 | ||
| 3659 | |||
| 3660 | extern "C" { | ||
| 3661 | 28970 | static void empty_signal_handler(int sig [[maybe_unused]]) {} | |
| 3662 | } | ||
| 3663 | |||
| 3664 | 12142 | void my_init_signals() { | |
| 3665 |
1/2✓ Branch 0 taken 12142 times.
✗ Branch 1 not taken.
|
12142 | DBUG_TRACE; |
| 3666 | struct sigaction sa; | ||
| 3667 | 12142 | (void)sigemptyset(&sa.sa_mask); | |
| 3668 | |||
| 3669 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 12122 times.
|
12142 | if (!(test_flags & TEST_NO_STACKTRACE) || |
| 3670 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | (test_flags & TEST_CORE_ON_SIGNAL)) { |
| 3671 | #ifdef HAVE_STACKTRACE | ||
| 3672 |
1/2✓ Branch 0 taken 12122 times.
✗ Branch 1 not taken.
|
12122 | my_init_stacktrace(); |
| 3673 | #endif | ||
| 3674 | |||
| 3675 |
2/2✓ Branch 0 taken 11594 times.
✓ Branch 1 taken 528 times.
|
12122 | if (test_flags & TEST_CORE_ON_SIGNAL) { |
| 3676 | // Change limits so that we will get a core file. | ||
| 3677 | struct rlimit rl; | ||
| 3678 | 11594 | rl.rlim_cur = rl.rlim_max = RLIM_INFINITY; | |
| 3679 |
1/18✗ Branch 0 not taken.
✓ Branch 1 taken 11594 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
|
11594 | if (setrlimit(RLIMIT_CORE, &rl)) LogErr(WARNING_LEVEL, ER_CORE_VALUES); |
| 3680 | } | ||
| 3681 | |||
| 3682 | /* | ||
| 3683 | SA_RESETHAND resets handler action to default when entering handler. | ||
| 3684 | SA_NODEFER allows receiving the same signal during handler. | ||
| 3685 | E.g. SIGABRT during our signal handler will dump core (default action). | ||
| 3686 | */ | ||
| 3687 | 12122 | sa.sa_flags = SA_RESETHAND | SA_NODEFER; | |
| 3688 | 12122 | sa.sa_handler = handle_fatal_signal; | |
| 3689 | // Treat these as fatal and handle them. | ||
| 3690 | 12122 | sigaction(SIGABRT, &sa, nullptr); | |
| 3691 | 12122 | sigaction(SIGFPE, &sa, nullptr); | |
| 3692 | // Handle these as well, except for ASAN/UBSAN builds: | ||
| 3693 | // we let sanitizer runtime handle them instead. | ||
| 3694 | #if defined(HANDLE_FATAL_SIGNALS) | ||
| 3695 | 12122 | sigaction(SIGBUS, &sa, nullptr); | |
| 3696 | 12122 | sigaction(SIGILL, &sa, nullptr); | |
| 3697 | 12122 | sigaction(SIGSEGV, &sa, nullptr); | |
| 3698 | #endif | ||
| 3699 | } | ||
| 3700 | |||
| 3701 | // Ignore SIGPIPE | ||
| 3702 | 12142 | sa.sa_flags = 0; | |
| 3703 | 12142 | sa.sa_handler = SIG_IGN; | |
| 3704 | 12142 | (void)sigaction(SIGPIPE, &sa, nullptr); | |
| 3705 | |||
| 3706 | // SIGALRM is used to interrupt the socket listener. | ||
| 3707 | 12142 | sa.sa_handler = empty_signal_handler; | |
| 3708 | 12142 | (void)sigaction(SIGALRM, &sa, nullptr); | |
| 3709 | |||
| 3710 | // Fix signals if ignored by parents (can happen on Mac OS X). | ||
| 3711 | 12142 | sa.sa_handler = SIG_DFL; | |
| 3712 | 12142 | (void)sigaction(SIGTERM, &sa, nullptr); | |
| 3713 | 12142 | (void)sigaction(SIGHUP, &sa, nullptr); | |
| 3714 | 12142 | (void)sigaction(SIGUSR1, &sa, nullptr); | |
| 3715 | |||
| 3716 | 12142 | (void)sigemptyset(&mysqld_signal_mask); | |
| 3717 | /* | ||
| 3718 | Block SIGQUIT, SIGHUP, SIGTERM, SIGUSR1 and SIGUSR2. | ||
| 3719 | The signal handler thread does sigwait() on these. | ||
| 3720 | */ | ||
| 3721 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGQUIT); | |
| 3722 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGHUP); | |
| 3723 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGTERM); | |
| 3724 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGTSTP); | |
| 3725 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGUSR1); | |
| 3726 | 12142 | (void)sigaddset(&mysqld_signal_mask, SIGUSR2); | |
| 3727 | /* | ||
| 3728 | Block SIGINT unless debugging to prevent Ctrl+C from causing | ||
| 3729 | unclean shutdown of the server. | ||
| 3730 | */ | ||
| 3731 |
2/2✓ Branch 0 taken 12107 times.
✓ Branch 1 taken 35 times.
|
12142 | if (!(test_flags & TEST_SIGINT)) (void)sigaddset(&mysqld_signal_mask, SIGINT); |
| 3732 | 12142 | pthread_sigmask(SIG_SETMASK, &mysqld_signal_mask, nullptr); | |
| 3733 | 12142 | } | |
| 3734 | |||
| 3735 | 11691 | static void start_signal_handler() { | |
| 3736 | int error; | ||
| 3737 | my_thread_attr_t thr_attr; | ||
| 3738 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | DBUG_TRACE; |
| 3739 | |||
| 3740 | 11691 | (void)my_thread_attr_init(&thr_attr); | |
| 3741 | 11691 | (void)pthread_attr_setscope(&thr_attr, PTHREAD_SCOPE_SYSTEM); | |
| 3742 | 11691 | (void)my_thread_attr_setdetachstate(&thr_attr, MY_THREAD_CREATE_JOINABLE); | |
| 3743 | |||
| 3744 | 11691 | size_t guardize = 0; | |
| 3745 | 11691 | (void)pthread_attr_getguardsize(&thr_attr, &guardize); | |
| 3746 | #if defined(__ia64__) || defined(__ia64) | ||
| 3747 | /* | ||
| 3748 | Peculiar things with ia64 platforms - it seems we only have half the | ||
| 3749 | stack size in reality, so we have to double it here | ||
| 3750 | */ | ||
| 3751 | guardize = my_thread_stack_size; | ||
| 3752 | #endif | ||
| 3753 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11691 times.
|
11691 | if (0 != |
| 3754 | 11691 | my_thread_attr_setstacksize(&thr_attr, my_thread_stack_size + guardize)) { | |
| 3755 | ✗ | assert(false); | |
| 3756 | } | ||
| 3757 | |||
| 3758 | /* | ||
| 3759 | Set main_thread_id so that SIGTERM/SIGQUIT/SIGKILL/SIGUSR2 can interrupt | ||
| 3760 | the socket listener successfully. | ||
| 3761 | */ | ||
| 3762 | 11691 | main_thread_id = my_thread_self(); | |
| 3763 | |||
| 3764 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_mutex_lock(&LOCK_start_signal_handler); |
| 3765 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
11691 | if ((error = mysql_thread_create(key_thread_signal_hand, &signal_thread_id, |
| 3766 | &thr_attr, signal_hand, nullptr))) { | ||
| 3767 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_CREATE_INTERRUPT_THREAD, error, errno); | |
| 3768 | ✗ | flush_error_log_messages(); | |
| 3769 | ✗ | exit(MYSQLD_ABORT_EXIT); | |
| 3770 | } | ||
| 3771 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_cond_wait(&COND_start_signal_handler, &LOCK_start_signal_handler); |
| 3772 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_mutex_unlock(&LOCK_start_signal_handler); |
| 3773 | |||
| 3774 | 11691 | (void)my_thread_attr_destroy(&thr_attr); | |
| 3775 | 11691 | } | |
| 3776 | |||
| 3777 | /** This thread handles SIGTERM, SIGQUIT, SIGHUP, SIGUSR1 and SIGUSR2 signals. | ||
| 3778 | */ | ||
| 3779 | /* ARGSUSED */ | ||
| 3780 | 11691 | extern "C" void *signal_hand(void *arg [[maybe_unused]]) { | |
| 3781 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | my_thread_init(); |
| 3782 | |||
| 3783 | sigset_t set; | ||
| 3784 | 11691 | (void)sigemptyset(&set); | |
| 3785 | 11691 | (void)sigaddset(&set, SIGTERM); | |
| 3786 | 11691 | (void)sigaddset(&set, SIGQUIT); | |
| 3787 | 11691 | (void)sigaddset(&set, SIGHUP); | |
| 3788 | 11691 | (void)sigaddset(&set, SIGUSR1); | |
| 3789 | 11691 | (void)sigaddset(&set, SIGUSR2); | |
| 3790 | |||
| 3791 | /* | ||
| 3792 | Signal to start_signal_handler that we are ready. | ||
| 3793 | This works by waiting for start_signal_handler to free mutex, | ||
| 3794 | after which we signal it that we are ready. | ||
| 3795 | */ | ||
| 3796 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_mutex_lock(&LOCK_start_signal_handler); |
| 3797 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_cond_broadcast(&COND_start_signal_handler); |
| 3798 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | mysql_mutex_unlock(&LOCK_start_signal_handler); |
| 3799 | |||
| 3800 | /* | ||
| 3801 | Wait until that all server components have been successfully initialized. | ||
| 3802 | This step is mandatory since signal processing can be done safely only when | ||
| 3803 | all server components have been initialized. | ||
| 3804 | */ | ||
| 3805 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | server_components_init_wait(); |
| 3806 | for (;;) { | ||
| 3807 | 11702 | int sig = 0; | |
| 3808 | int rc; | ||
| 3809 | bool error; | ||
| 3810 | #ifdef __APPLE__ | ||
| 3811 | while ((rc = sigwait(&set, &sig)) == EINTR) { | ||
| 3812 | } | ||
| 3813 | error = rc != 0; | ||
| 3814 | #else | ||
| 3815 | siginfo_t sig_info; | ||
| 3816 |
6/8✓ Branch 0 taken 10147 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 33 times.
✓ Branch 3 taken 10114 times.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 33 times.
✓ Branch 7 taken 10114 times.
|
11735 | while ((rc = sigwaitinfo(&set, &sig_info)) == -1 && errno == EINTR) { |
| 3817 | } | ||
| 3818 | 10114 | error = rc == -1; | |
| 3819 |
1/2✓ Branch 0 taken 10114 times.
✗ Branch 1 not taken.
|
10114 | if (!error) sig = sig_info.si_signo; |
| 3820 | #endif // __APPLE__ | ||
| 3821 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10114 times.
|
10114 | if (error) |
| 3822 | ✗ | sql_print_error( | |
| 3823 | "Fatal error in signal handling thread. sigwait/sigwaitinfo returned " | ||
| 3824 | "error %d\n. Exiting signal handler " | ||
| 3825 | "thread.", | ||
| 3826 | errno); | ||
| 3827 | |||
| 3828 |
2/4✓ Branch 0 taken 10114 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10114 times.
|
10114 | if (error || cleanup_done) { |
| 3829 | ✗ | my_thread_end(); | |
| 3830 | ✗ | my_thread_exit(nullptr); // Safety | |
| 3831 | return nullptr; // Avoid compiler warnings | ||
| 3832 | } | ||
| 3833 |
4/5✓ Branch 0 taken 56 times.
✓ Branch 1 taken 10047 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
|
10114 | switch (sig) { |
| 3834 | 56 | case SIGUSR2: | |
| 3835 | 56 | signal_hand_thr_exit_code = MYSQLD_RESTART_EXIT; | |
| 3836 | #ifndef __APPLE__ // Mac OS doesn't have sigwaitinfo. | ||
| 3837 | // Log a note if mysqld is restarted via kill command. | ||
| 3838 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 56 times.
|
56 | if (sig_info.si_pid != getpid()) { |
| 3839 | ✗ | sql_print_information( | |
| 3840 | "Received signal SIGUSR2." | ||
| 3841 | " Restarting mysqld (Version %s)", | ||
| 3842 | server_version); | ||
| 3843 | } | ||
| 3844 | #endif // __APPLE__ | ||
| 3845 | [[fallthrough]]; | ||
| 3846 | case SIGTERM: | ||
| 3847 | case SIGQUIT: | ||
| 3848 | #ifndef __APPLE__ // Mac OS doesn't have sigwaitinfo. | ||
| 3849 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 10097 times.
|
10103 | if (sig_info.si_pid != getpid()) |
| 3850 |
8/16✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
|
6 | LogErr(SYSTEM_LEVEL, ER_SERVER_SHUTDOWN_INFO, "<via user signal>", |
| 3851 | server_version, MYSQL_COMPILATION_COMMENT_SERVER); | ||
| 3852 | #else | ||
| 3853 | LogErr(SYSTEM_LEVEL, ER_SERVER_SHUTDOWN_INFO, "<via user signal>", | ||
| 3854 | server_version, MYSQL_COMPILATION_COMMENT_SERVER); | ||
| 3855 | #endif // __APPLE__ | ||
| 3856 | // Switch to the file log message processing. | ||
| 3857 |
3/4✓ Branch 0 taken 10102 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
|
10103 | query_logger.set_handlers((log_output_options != LOG_NONE) ? LOG_FILE |
| 3858 | : LOG_NONE); | ||
| 3859 |
3/8✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10103 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10103 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
10103 | DBUG_PRINT("info", |
| 3860 | ("Got signal: %d connection_events_loop_aborted: %d", sig, | ||
| 3861 | connection_events_loop_aborted())); | ||
| 3862 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | if (!connection_events_loop_aborted()) { |
| 3863 | // Mark abort for threads. | ||
| 3864 | 10103 | set_connection_events_loop_aborted(true); | |
| 3865 | #ifdef HAVE_PSI_THREAD_INTERFACE | ||
| 3866 | // Delete the instrumentation for the signal thread. | ||
| 3867 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | PSI_THREAD_CALL(delete_current_thread)(); |
| 3868 | #endif /* HAVE_PSI_THREAD_INTERFACE */ | ||
| 3869 | /* | ||
| 3870 | Kill the socket listener. | ||
| 3871 | The main thread will then set socket_listener_active= false, | ||
| 3872 | and wait for us to finish all the cleanup below. | ||
| 3873 | */ | ||
| 3874 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | mysql_mutex_lock(&LOCK_socket_listener_active); |
| 3875 |
2/2✓ Branch 0 taken 9813 times.
✓ Branch 1 taken 10103 times.
|
19916 | while (socket_listener_active) { |
| 3876 |
3/8✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9813 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
9813 | DBUG_PRINT("info", ("Killing socket listener")); |
| 3877 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9813 times.
|
9813 | if (pthread_kill(main_thread_id, SIGALRM)) { |
| 3878 | ✗ | assert(false); | |
| 3879 | break; | ||
| 3880 | } | ||
| 3881 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | mysql_cond_wait(&COND_socket_listener_active, |
| 3882 | &LOCK_socket_listener_active); | ||
| 3883 | } | ||
| 3884 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | mysql_mutex_unlock(&LOCK_socket_listener_active); |
| 3885 | |||
| 3886 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | close_connections(); |
| 3887 | } | ||
| 3888 |
1/2✓ Branch 0 taken 10103 times.
✗ Branch 1 not taken.
|
10103 | my_thread_end(); |
| 3889 | 10103 | my_thread_exit(nullptr); | |
| 3890 | return nullptr; // Avoid compiler warnings | ||
| 3891 | break; | ||
| 3892 | 4 | case SIGHUP: | |
| 3893 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | if (!connection_events_loop_aborted()) { |
| 3894 | int not_used; | ||
| 3895 |
5/8✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 2 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
|
4 | DBUG_EXECUTE_IF("simulate_sighup_print_status", { |
| 3896 | printf("\nStatus information:\n\n"); | ||
| 3897 | fflush(stdout); | ||
| 3898 | }); | ||
| 3899 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | handle_reload_request( |
| 3900 | nullptr, | ||
| 3901 | (REFRESH_LOG | REFRESH_TABLES | REFRESH_FAST | REFRESH_GRANT | | ||
| 3902 | REFRESH_THREADS | REFRESH_HOSTS), | ||
| 3903 | nullptr, ¬_used); // Flush logs | ||
| 3904 | // Re-enable query logs after the options were reloaded. | ||
| 3905 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | query_logger.set_handlers(log_output_options); |
| 3906 | } | ||
| 3907 | 4 | break; | |
| 3908 | 7 | case SIGUSR1: | |
| 3909 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | if (!connection_events_loop_aborted()) { |
| 3910 | int not_used; | ||
| 3911 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | handle_reload_request( |
| 3912 | nullptr, | ||
| 3913 | (REFRESH_ERROR_LOG | /**< Rotate only the error log */ | ||
| 3914 | REFRESH_GENERAL_LOG | /**< Flush the general log */ | ||
| 3915 | REFRESH_SLOW_LOG), /**< Flush the slow query log */ | ||
| 3916 | nullptr, ¬_used); // Flush logs | ||
| 3917 | // Re-enable query logs after the options were reloaded. | ||
| 3918 |
1/2✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
|
7 | query_logger.set_handlers(log_output_options); |
| 3919 | } | ||
| 3920 | 7 | break; | |
| 3921 | ✗ | default: | |
| 3922 | ✗ | break; /* purecov: tested */ | |
| 3923 | } | ||
| 3924 | 11 | } | |
| 3925 | return nullptr; /* purecov: deadcode */ | ||
| 3926 | } | ||
| 3927 | |||
| 3928 | #endif // !_WIN32 | ||
| 3929 | |||
| 3930 | /** | ||
| 3931 | All global error messages are sent here where the first one is stored | ||
| 3932 | for the client. | ||
| 3933 | */ | ||
| 3934 | /* ARGSUSED */ | ||
| 3935 | extern "C" void my_message_sql(uint error, const char *str, myf MyFlags); | ||
| 3936 | |||
| 3937 | 2357605 | void my_message_sql(uint error, const char *str, myf MyFlags) { | |
| 3938 |
1/2✓ Branch 0 taken 2357614 times.
✗ Branch 1 not taken.
|
2357605 | THD *thd = current_thd; |
| 3939 |
1/2✓ Branch 0 taken 2357622 times.
✗ Branch 1 not taken.
|
2357614 | DBUG_TRACE; |
| 3940 |
5/8✓ Branch 0 taken 2357623 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2357621 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 2357605 times.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
|
2357622 | DBUG_PRINT("error", ("error: %u message: '%s'", error, str)); |
| 3941 | |||
| 3942 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2357620 times.
|
2357620 | assert(str != nullptr); |
| 3943 | /* | ||
| 3944 | An error should have a valid error number (!= 0), so it can be caught | ||
| 3945 | in stored procedures by SQL exception handlers. | ||
| 3946 | Calling my_error() with error == 0 is a bug. | ||
| 3947 | Remaining known places to fix: | ||
| 3948 | - storage/myisam/mi_create.c, my_printf_error() | ||
| 3949 | TODO: | ||
| 3950 | assert(error != 0); | ||
| 3951 | */ | ||
| 3952 | |||
| 3953 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2357619 times.
|
2357620 | if (error == 0) { |
| 3954 | /* At least, prevent new abuse ... */ | ||
| 3955 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | assert(strncmp(str, "MyISAM table", 12) == 0); |
| 3956 | 1 | error = ER_UNKNOWN_ERROR; | |
| 3957 | } | ||
| 3958 | |||
| 3959 | /* Caller wishes to inform client, and one is attached. */ | ||
| 3960 |
2/2✓ Branch 0 taken 2357271 times.
✓ Branch 1 taken 349 times.
|
2357620 | if (thd) { |
| 3961 | 2357271 | (void)thd->raise_condition(error, nullptr, Sql_condition::SL_ERROR, str, | |
| 3962 |
1/2✓ Branch 0 taken 2357268 times.
✗ Branch 1 not taken.
|
2357271 | MyFlags & ME_FATALERROR); |
| 3963 | |||
| 3964 | /* | ||
| 3965 | Now for an argument check. | ||
| 3966 | We're asserting after rather than before raising the | ||
| 3967 | condition to make the culprit easier to track down. | ||
| 3968 | |||
| 3969 | Messages intended for the error-log are in the range | ||
| 3970 | starting at ER_SERVER_RANGE_START (error_code 10,000); | ||
| 3971 | messages intended for sending to a client are in the | ||
| 3972 | range below ER_SERVER_RANGE_START. If a message is to | ||
| 3973 | be sent to both a client and the error log, it must | ||
| 3974 | be added twice (once in each range), and two separate | ||
| 3975 | calls (e.g. my_error() and LogErr()) must be added to | ||
| 3976 | the code. | ||
| 3977 | |||
| 3978 | Only error-codes from the client range should be seen | ||
| 3979 | in this if(). If your patch asserts here, one of two | ||
| 3980 | things probably happened: | ||
| 3981 | |||
| 3982 | - You added a new message to messages_to_error_log.txt: | ||
| 3983 | The message was added to the server range, but code | ||
| 3984 | was added that tries to send the message to a client | ||
| 3985 | (my_error(), push_warning_printf(), etc.). | ||
| 3986 | |||
| 3987 | => Move the new message to messages_to_clients.txt. | ||
| 3988 | The copied message should be added at the end of | ||
| 3989 | the range for the lowest server version you're adding | ||
| 3990 | the message to. | ||
| 3991 | Rebuild the server; rerun your test. | ||
| 3992 | |||
| 3993 | - You used an existing message: | ||
| 3994 | The existing message is intended for use with | ||
| 3995 | the error-log (it appears in messages_to_error_log.txt), | ||
| 3996 | but the new code tries to send it to a client (my_error(), | ||
| 3997 | push_warning_printf(), etc.). | ||
| 3998 | |||
| 3999 | => Copy the existing message to messages_to_clients.txt. | ||
| 4000 | - The copied message should be added at the end of | ||
| 4001 | the range for the lowest server version you're adding | ||
| 4002 | the message to. | ||
| 4003 | - The copied message will need its own symbol; | ||
| 4004 | if in doubt, call the copy of ER_EXAMPLE_MESSAGE | ||
| 4005 | ER_DA_EXAMPLE_MESSAGE (as this version is for use | ||
| 4006 | with the diagnostics area). | ||
| 4007 | Then make sure that your new code references | ||
| 4008 | this new symbol when it sends the message | ||
| 4009 | to a client. | ||
| 4010 | Rebuild the server; rerun your test. | ||
| 4011 | |||
| 4012 | We'll assert this here (rather than in raise_condition) as | ||
| 4013 | SQL's SIGNAL command also calls raise_condition, and SIGNAL | ||
| 4014 | is currently allowed to set any error-code (regardless of | ||
| 4015 | range). SIGNALing an error-code from the error-log range | ||
| 4016 | will not result in writing to that log to prevent abuse. | ||
| 4017 | */ | ||
| 4018 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2357268 times.
|
2357268 | assert(error < ER_SERVER_RANGE_START); |
| 4019 | } | ||
| 4020 | |||
| 4021 | /* When simulating OOM, skip writing to error log to avoid mtr errors */ | ||
| 4022 |
3/4✓ Branch 0 taken 2357619 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 2357607 times.
|
2357617 | DBUG_EXECUTE_IF("simulate_out_of_memory", return;); |
| 4023 | |||
| 4024 | /* | ||
| 4025 | Caller wishes to send to both the client and the error-log. | ||
| 4026 | This is legacy behaviour that is no longer legal as errors flagged | ||
| 4027 | to a client and those sent to the error-log are in different | ||
| 4028 | numeric ranges now. If you own code that does this, see about | ||
| 4029 | updating it by splitting it into two calls, one sending status | ||
| 4030 | to the client, the other sending it to the error-log using | ||
| 4031 | LogErr() and friends. | ||
| 4032 | */ | ||
| 4033 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2357605 times.
|
2357607 | if (MyFlags & ME_ERRORLOG) { |
| 4034 | /* | ||
| 4035 | We've removed most uses of ME_ERRORLOG in the server. | ||
| 4036 | This leaves three possible cases, in which we'll rewrite | ||
| 4037 | the error-code from one in the client-range to one in | ||
| 4038 | the error-log range here: | ||
| 4039 | |||
| 4040 | - EE_OUTOFMEMORY: Correct to ER_SERVER_OUT_OF_RESOURCES so | ||
| 4041 | mysys can remain logger-agnostic. | ||
| 4042 | |||
| 4043 | - HA_* range: Correct to catch-all ER_SERVER_HANDLER_ERROR. | ||
| 4044 | |||
| 4045 | - otherwise: Flag as using info from the diagnostics area | ||
| 4046 | (ER_ERROR_INFO_FROM_DA). This is a failsafe; | ||
| 4047 | if your code triggers it, your code is probably | ||
| 4048 | wrong. | ||
| 4049 | */ | ||
| 4050 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | if ((error == EE_OUTOFMEMORY) || (error == HA_ERR_OUT_OF_MEM)) |
| 4051 | ✗ | error = ER_SERVER_OUT_OF_RESOURCES; | |
| 4052 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | else if (error <= HA_ERR_LAST) |
| 4053 | 2 | error = ER_SERVER_HANDLER_ERROR; | |
| 4054 | |||
| 4055 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (error < ER_SERVER_RANGE_START) |
| 4056 | ✗ | LogEvent() | |
| 4057 | ✗ | .type(LOG_TYPE_ERROR) | |
| 4058 | ✗ | .prio(ERROR_LEVEL) | |
| 4059 | ✗ | .errcode(ER_ERROR_INFO_FROM_DA) | |
| 4060 | ✗ | .lookup(ER_ERROR_INFO_FROM_DA, error, str); | |
| 4061 | else | ||
| 4062 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
4 | LogEvent() |
| 4063 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | .type(LOG_TYPE_ERROR) |
| 4064 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | .prio(ERROR_LEVEL) |
| 4065 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | .errcode(error) |
| 4066 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | .verbatim(str); |
| 4067 | |||
| 4068 | /* | ||
| 4069 | This is no longer supported behaviour except for the cases | ||
| 4070 | outlined above, so flag anything else in debug builds! | ||
| 4071 | (We're bailing after rather than before printing to make the | ||
| 4072 | culprit easier to track down.) | ||
| 4073 | */ | ||
| 4074 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
|
2 | assert((error == ER_FEATURE_NOT_AVAILABLE) || |
| 4075 | (error >= ER_SERVER_RANGE_START)); | ||
| 4076 | } | ||
| 4077 | |||
| 4078 | /* | ||
| 4079 | Caller wishes to send to client, but none is attached, so we send | ||
| 4080 | to error-log instead. | ||
| 4081 | */ | ||
| 4082 |
2/2✓ Branch 0 taken 348 times.
✓ Branch 1 taken 2357257 times.
|
2357605 | else if (!thd) { |
| 4083 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
696 | LogEvent() |
| 4084 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
348 | .type(LOG_TYPE_ERROR) |
| 4085 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
348 | .subsys(LOG_SUBSYSTEM_TAG) |
| 4086 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
348 | .prio(ERROR_LEVEL) |
| 4087 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
✓ Branch 2 taken 348 times.
✗ Branch 3 not taken.
|
348 | .errcode((error < ER_SERVER_RANGE_START) |
| 4088 | ? ER_SERVER_NO_SESSION_TO_SEND_TO | ||
| 4089 | : error) | ||
| 4090 |
1/2✓ Branch 0 taken 348 times.
✗ Branch 1 not taken.
|
348 | .lookup(ER_SERVER_NO_SESSION_TO_SEND_TO, error, str); |
| 4091 | } | ||
| 4092 |
2/2✓ Branch 0 taken 2357607 times.
✓ Branch 1 taken 12 times.
|
2357619 | } |
| 4093 | |||
| 4094 | extern "C" void *my_str_malloc_mysqld(size_t size); | ||
| 4095 | extern "C" void my_str_free_mysqld(void *ptr); | ||
| 4096 | extern "C" void *my_str_realloc_mysqld(void *ptr, size_t size); | ||
| 4097 | |||
| 4098 | 13 | void *my_str_malloc_mysqld(size_t size) { | |
| 4099 | 13 | return my_malloc(key_memory_my_str_malloc, size, MYF(MY_FAE)); | |
| 4100 | } | ||
| 4101 | |||
| 4102 | 13 | void my_str_free_mysqld(void *ptr) { my_free(ptr); } | |
| 4103 | |||
| 4104 | ✗ | void *my_str_realloc_mysqld(void *ptr, size_t size) { | |
| 4105 | ✗ | return my_realloc(key_memory_my_str_malloc, ptr, size, MYF(MY_FAE)); | |
| 4106 | } | ||
| 4107 | |||
| 4108 | const char *load_default_groups[] = { | ||
| 4109 | #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE | ||
| 4110 | "mysql_cluster", | ||
| 4111 | #endif | ||
| 4112 | "mysqld", "server", MYSQL_BASE_VERSION, nullptr, nullptr}; | ||
| 4113 | |||
| 4114 | #if defined(_WIN32) | ||
| 4115 | static const int load_default_groups_sz = | ||
| 4116 | sizeof(load_default_groups) / sizeof(load_default_groups[0]); | ||
| 4117 | #endif | ||
| 4118 | |||
| 4119 | /** | ||
| 4120 | This function is used to check for stack overrun for pathological | ||
| 4121 | cases of regular expressions and 'like' expressions. | ||
| 4122 | The call to current_thd is quite expensive, so we try to avoid it | ||
| 4123 | for the normal cases. | ||
| 4124 | The size of each stack frame for the wildcmp() routines is ~128 bytes, | ||
| 4125 | so checking *every* recursive call is not necessary. | ||
| 4126 | */ | ||
| 4127 | extern "C" { | ||
| 4128 | 144720298 | static int check_enough_stack_size(int recurse_level) { | |
| 4129 | uchar stack_top; | ||
| 4130 |
1/2✓ Branch 0 taken 144720298 times.
✗ Branch 1 not taken.
|
144720298 | if (recurse_level % 16 != 0) return 0; |
| 4131 | |||
| 4132 | ✗ | THD *my_thd = current_thd; | |
| 4133 | ✗ | if (my_thd != nullptr) | |
| 4134 | ✗ | return check_stack_overrun(my_thd, STACK_MIN_SIZE * 4, &stack_top); | |
| 4135 | ✗ | return 0; | |
| 4136 | } | ||
| 4137 | } // extern "C" | ||
| 4138 | |||
| 4139 | SHOW_VAR com_status_vars[] = { | ||
| 4140 | {"admin_commands", (char *)offsetof(System_status_var, com_other), | ||
| 4141 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4142 | {"assign_to_keycache", | ||
| 4143 | (char *)offsetof(System_status_var, | ||
| 4144 | com_stat[(uint)SQLCOM_ASSIGN_TO_KEYCACHE]), | ||
| 4145 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4146 | {"alter_db", | ||
| 4147 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_DB]), | ||
| 4148 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4149 | {"alter_event", | ||
| 4150 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_EVENT]), | ||
| 4151 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4152 | {"alter_function", | ||
| 4153 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_FUNCTION]), | ||
| 4154 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4155 | {"alter_instance", | ||
| 4156 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_INSTANCE]), | ||
| 4157 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4158 | {"alter_procedure", | ||
| 4159 | (char *)offsetof(System_status_var, | ||
| 4160 | com_stat[(uint)SQLCOM_ALTER_PROCEDURE]), | ||
| 4161 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4162 | {"alter_resource_group", | ||
| 4163 | (char *)offsetof(System_status_var, | ||
| 4164 | com_stat[(uint)SQLCOM_ALTER_RESOURCE_GROUP]), | ||
| 4165 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4166 | {"alter_server", | ||
| 4167 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_SERVER]), | ||
| 4168 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4169 | {"alter_table", | ||
| 4170 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_TABLE]), | ||
| 4171 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4172 | {"alter_tablespace", | ||
| 4173 | (char *)offsetof(System_status_var, | ||
| 4174 | com_stat[(uint)SQLCOM_ALTER_TABLESPACE]), | ||
| 4175 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4176 | {"alter_user", | ||
| 4177 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ALTER_USER]), | ||
| 4178 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4179 | {"alter_user_default_role", | ||
| 4180 | (char *)offsetof(System_status_var, | ||
| 4181 | com_stat[(uint)SQLCOM_ALTER_USER_DEFAULT_ROLE]), | ||
| 4182 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4183 | {"analyze", | ||
| 4184 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ANALYZE]), | ||
| 4185 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4186 | {"begin", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_BEGIN]), | ||
| 4187 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4188 | {"binlog", | ||
| 4189 | (char *)offsetof(System_status_var, | ||
| 4190 | com_stat[(uint)SQLCOM_BINLOG_BASE64_EVENT]), | ||
| 4191 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4192 | {"call_procedure", | ||
| 4193 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CALL]), | ||
| 4194 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4195 | {"change_db", | ||
| 4196 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_DB]), | ||
| 4197 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4198 | {"change_master", | ||
| 4199 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_MASTER]), | ||
| 4200 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4201 | {"change_repl_filter", | ||
| 4202 | (char *)offsetof(System_status_var, | ||
| 4203 | com_stat[(uint)SQLCOM_CHANGE_REPLICATION_FILTER]), | ||
| 4204 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4205 | {"change_replication_source", | ||
| 4206 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHANGE_MASTER]), | ||
| 4207 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4208 | {"check", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHECK]), | ||
| 4209 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4210 | {"checksum", | ||
| 4211 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CHECKSUM]), | ||
| 4212 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4213 | {"clone", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CLONE]), | ||
| 4214 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4215 | {"commit", | ||
| 4216 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_COMMIT]), | ||
| 4217 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4218 | {"create_compression_dictionary", | ||
| 4219 | (char *)offsetof(System_status_var, | ||
| 4220 | com_stat[(uint)SQLCOM_CREATE_COMPRESSION_DICTIONARY]), | ||
| 4221 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4222 | {"create_db", | ||
| 4223 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_DB]), | ||
| 4224 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4225 | {"create_event", | ||
| 4226 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_EVENT]), | ||
| 4227 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4228 | {"create_function", | ||
| 4229 | (char *)offsetof(System_status_var, | ||
| 4230 | com_stat[(uint)SQLCOM_CREATE_SPFUNCTION]), | ||
| 4231 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4232 | {"create_index", | ||
| 4233 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_INDEX]), | ||
| 4234 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4235 | {"create_procedure", | ||
| 4236 | (char *)offsetof(System_status_var, | ||
| 4237 | com_stat[(uint)SQLCOM_CREATE_PROCEDURE]), | ||
| 4238 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4239 | {"create_role", | ||
| 4240 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_ROLE]), | ||
| 4241 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4242 | {"create_server", | ||
| 4243 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_SERVER]), | ||
| 4244 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4245 | {"create_table", | ||
| 4246 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_TABLE]), | ||
| 4247 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4248 | {"create_resource_group", | ||
| 4249 | (char *)offsetof(System_status_var, | ||
| 4250 | com_stat[(uint)SQLCOM_CREATE_RESOURCE_GROUP]), | ||
| 4251 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4252 | {"create_trigger", | ||
| 4253 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_TRIGGER]), | ||
| 4254 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4255 | {"create_udf", | ||
| 4256 | (char *)offsetof(System_status_var, | ||
| 4257 | com_stat[(uint)SQLCOM_CREATE_FUNCTION]), | ||
| 4258 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4259 | {"create_user", | ||
| 4260 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_USER]), | ||
| 4261 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4262 | {"create_view", | ||
| 4263 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_VIEW]), | ||
| 4264 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4265 | {"create_spatial_reference_system", | ||
| 4266 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_CREATE_SRS]), | ||
| 4267 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4268 | {"dealloc_sql", | ||
| 4269 | (char *)offsetof(System_status_var, | ||
| 4270 | com_stat[(uint)SQLCOM_DEALLOCATE_PREPARE]), | ||
| 4271 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4272 | {"delete", | ||
| 4273 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DELETE]), | ||
| 4274 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4275 | {"delete_multi", | ||
| 4276 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DELETE_MULTI]), | ||
| 4277 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4278 | {"do", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DO]), | ||
| 4279 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4280 | {"drop_compression_dictionary", | ||
| 4281 | (char *)offsetof(System_status_var, | ||
| 4282 | com_stat[(uint)SQLCOM_DROP_COMPRESSION_DICTIONARY]), | ||
| 4283 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4284 | {"drop_db", | ||
| 4285 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_DB]), | ||
| 4286 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4287 | {"drop_event", | ||
| 4288 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_EVENT]), | ||
| 4289 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4290 | {"drop_function", | ||
| 4291 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_FUNCTION]), | ||
| 4292 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4293 | {"drop_index", | ||
| 4294 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_INDEX]), | ||
| 4295 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4296 | {"drop_procedure", | ||
| 4297 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_PROCEDURE]), | ||
| 4298 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4299 | {"drop_resource_group", | ||
| 4300 | (char *)offsetof(System_status_var, | ||
| 4301 | com_stat[(uint)SQLCOM_DROP_RESOURCE_GROUP]), | ||
| 4302 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4303 | {"drop_role", | ||
| 4304 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_ROLE]), | ||
| 4305 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4306 | {"drop_server", | ||
| 4307 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_SERVER]), | ||
| 4308 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4309 | {"drop_spatial_reference_system", | ||
| 4310 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_SRS]), | ||
| 4311 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4312 | {"drop_table", | ||
| 4313 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_TABLE]), | ||
| 4314 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4315 | {"drop_trigger", | ||
| 4316 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_TRIGGER]), | ||
| 4317 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4318 | {"drop_user", | ||
| 4319 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_USER]), | ||
| 4320 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4321 | {"drop_view", | ||
| 4322 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_DROP_VIEW]), | ||
| 4323 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4324 | {"empty_query", | ||
| 4325 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_EMPTY_QUERY]), | ||
| 4326 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4327 | {"execute_sql", | ||
| 4328 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_EXECUTE]), | ||
| 4329 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4330 | {"explain_other", | ||
| 4331 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_EXPLAIN_OTHER]), | ||
| 4332 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4333 | {"flush", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_FLUSH]), | ||
| 4334 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4335 | {"get_diagnostics", | ||
| 4336 | (char *)offsetof(System_status_var, | ||
| 4337 | com_stat[(uint)SQLCOM_GET_DIAGNOSTICS]), | ||
| 4338 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4339 | {"grant", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_GRANT]), | ||
| 4340 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4341 | {"grant_roles", | ||
| 4342 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_GRANT_ROLE]), | ||
| 4343 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4344 | {"ha_close", | ||
| 4345 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_HA_CLOSE]), | ||
| 4346 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4347 | {"ha_open", | ||
| 4348 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_HA_OPEN]), | ||
| 4349 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4350 | {"ha_read", | ||
| 4351 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_HA_READ]), | ||
| 4352 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4353 | {"help", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_HELP]), | ||
| 4354 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4355 | {"import", | ||
| 4356 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_IMPORT]), | ||
| 4357 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4358 | {"insert", | ||
| 4359 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_INSERT]), | ||
| 4360 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4361 | {"insert_select", | ||
| 4362 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_INSERT_SELECT]), | ||
| 4363 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4364 | {"install_component", | ||
| 4365 | (char *)offsetof(System_status_var, | ||
| 4366 | com_stat[(uint)SQLCOM_INSTALL_COMPONENT]), | ||
| 4367 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4368 | {"install_plugin", | ||
| 4369 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_INSTALL_PLUGIN]), | ||
| 4370 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4371 | {"kill", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_KILL]), | ||
| 4372 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4373 | {"load", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_LOAD]), | ||
| 4374 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4375 | {"lock_instance", | ||
| 4376 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_LOCK_INSTANCE]), | ||
| 4377 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4378 | {"lock_tables", | ||
| 4379 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_LOCK_TABLES]), | ||
| 4380 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4381 | {"lock_tables_for_backup", | ||
| 4382 | (char *)offsetof(System_status_var, | ||
| 4383 | com_stat[(uint)SQLCOM_LOCK_TABLES_FOR_BACKUP]), | ||
| 4384 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4385 | {"optimize", | ||
| 4386 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_OPTIMIZE]), | ||
| 4387 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4388 | {"preload_keys", | ||
| 4389 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_PRELOAD_KEYS]), | ||
| 4390 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4391 | {"prepare_sql", | ||
| 4392 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_PREPARE]), | ||
| 4393 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4394 | {"purge", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_PURGE]), | ||
| 4395 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4396 | {"purge_before_date", | ||
| 4397 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_PURGE_BEFORE]), | ||
| 4398 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4399 | {"release_savepoint", | ||
| 4400 | (char *)offsetof(System_status_var, | ||
| 4401 | com_stat[(uint)SQLCOM_RELEASE_SAVEPOINT]), | ||
| 4402 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4403 | {"rename_table", | ||
| 4404 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_RENAME_TABLE]), | ||
| 4405 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4406 | {"rename_user", | ||
| 4407 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_RENAME_USER]), | ||
| 4408 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4409 | {"repair", | ||
| 4410 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REPAIR]), | ||
| 4411 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4412 | {"replace", | ||
| 4413 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REPLACE]), | ||
| 4414 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4415 | {"replace_select", | ||
| 4416 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REPLACE_SELECT]), | ||
| 4417 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4418 | {"reset", (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_RESET]), | ||
| 4419 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4420 | {"resignal", | ||
| 4421 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_RESIGNAL]), | ||
| 4422 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4423 | {"restart", | ||
| 4424 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_RESTART_SERVER]), | ||
| 4425 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4426 | {"revoke", | ||
| 4427 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REVOKE]), | ||
| 4428 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4429 | {"revoke_all", | ||
| 4430 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REVOKE_ALL]), | ||
| 4431 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4432 | {"revoke_roles", | ||
| 4433 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_REVOKE_ROLE]), | ||
| 4434 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4435 | {"rollback", | ||
| 4436 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_ROLLBACK]), | ||
| 4437 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4438 | {"rollback_to_savepoint", | ||
| 4439 | (char *)offsetof(System_status_var, | ||
| 4440 | com_stat[(uint)SQLCOM_ROLLBACK_TO_SAVEPOINT]), | ||
| 4441 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4442 | {"savepoint", | ||
| 4443 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SAVEPOINT]), | ||
| 4444 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4445 | {"select", | ||
| 4446 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SELECT]), | ||
| 4447 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4448 | {"set_option", | ||
| 4449 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SET_OPTION]), | ||
| 4450 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4451 | {"set_password", | ||
| 4452 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SET_PASSWORD]), | ||
| 4453 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4454 | {"set_resource_group", | ||
| 4455 | (char *)offsetof(System_status_var, | ||
| 4456 | com_stat[(uint)SQLCOM_SET_RESOURCE_GROUP]), | ||
| 4457 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4458 | {"set_role", | ||
| 4459 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SET_ROLE]), | ||
| 4460 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4461 | {"signal", | ||
| 4462 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SIGNAL]), | ||
| 4463 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4464 | {"show_binlog_events", | ||
| 4465 | (char *)offsetof(System_status_var, | ||
| 4466 | com_stat[(uint)SQLCOM_SHOW_BINLOG_EVENTS]), | ||
| 4467 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4468 | {"show_binlogs", | ||
| 4469 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_BINLOGS]), | ||
| 4470 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4471 | {"show_charsets", | ||
| 4472 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_CHARSETS]), | ||
| 4473 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4474 | {"show_client_statistics", | ||
| 4475 | (char *)offsetof(System_status_var, | ||
| 4476 | com_stat[(uint)SQLCOM_SHOW_CLIENT_STATS]), | ||
| 4477 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4478 | {"show_collations", | ||
| 4479 | (char *)offsetof(System_status_var, | ||
| 4480 | com_stat[(uint)SQLCOM_SHOW_COLLATIONS]), | ||
| 4481 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4482 | {"show_create_db", | ||
| 4483 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_CREATE_DB]), | ||
| 4484 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4485 | {"show_create_event", | ||
| 4486 | (char *)offsetof(System_status_var, | ||
| 4487 | com_stat[(uint)SQLCOM_SHOW_CREATE_EVENT]), | ||
| 4488 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4489 | {"show_create_func", | ||
| 4490 | (char *)offsetof(System_status_var, | ||
| 4491 | com_stat[(uint)SQLCOM_SHOW_CREATE_FUNC]), | ||
| 4492 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4493 | {"show_create_proc", | ||
| 4494 | (char *)offsetof(System_status_var, | ||
| 4495 | com_stat[(uint)SQLCOM_SHOW_CREATE_PROC]), | ||
| 4496 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4497 | {"show_create_table", | ||
| 4498 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_CREATE]), | ||
| 4499 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4500 | {"show_create_trigger", | ||
| 4501 | (char *)offsetof(System_status_var, | ||
| 4502 | com_stat[(uint)SQLCOM_SHOW_CREATE_TRIGGER]), | ||
| 4503 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4504 | {"show_databases", | ||
| 4505 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_DATABASES]), | ||
| 4506 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4507 | {"show_engine_logs", | ||
| 4508 | (char *)offsetof(System_status_var, | ||
| 4509 | com_stat[(uint)SQLCOM_SHOW_ENGINE_LOGS]), | ||
| 4510 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4511 | {"show_engine_mutex", | ||
| 4512 | (char *)offsetof(System_status_var, | ||
| 4513 | com_stat[(uint)SQLCOM_SHOW_ENGINE_MUTEX]), | ||
| 4514 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4515 | {"show_engine_status", | ||
| 4516 | (char *)offsetof(System_status_var, | ||
| 4517 | com_stat[(uint)SQLCOM_SHOW_ENGINE_STATUS]), | ||
| 4518 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4519 | {"show_events", | ||
| 4520 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_EVENTS]), | ||
| 4521 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4522 | {"show_errors", | ||
| 4523 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_ERRORS]), | ||
| 4524 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4525 | {"show_fields", | ||
| 4526 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_FIELDS]), | ||
| 4527 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4528 | {"show_function_code", | ||
| 4529 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_FUNC_CODE]), | ||
| 4530 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4531 | {"show_function_status", | ||
| 4532 | (char *)offsetof(System_status_var, | ||
| 4533 | com_stat[(uint)SQLCOM_SHOW_STATUS_FUNC]), | ||
| 4534 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4535 | {"show_grants", | ||
| 4536 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_GRANTS]), | ||
| 4537 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4538 | {"show_index_statistics", | ||
| 4539 | (char *)offsetof(System_status_var, | ||
| 4540 | com_stat[(uint)SQLCOM_SHOW_INDEX_STATS]), | ||
| 4541 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4542 | {"show_keys", | ||
| 4543 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_KEYS]), | ||
| 4544 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4545 | {"show_master_status", | ||
| 4546 | (char *)offsetof(System_status_var, | ||
| 4547 | com_stat[(uint)SQLCOM_SHOW_MASTER_STAT]), | ||
| 4548 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4549 | {"show_open_tables", | ||
| 4550 | (char *)offsetof(System_status_var, | ||
| 4551 | com_stat[(uint)SQLCOM_SHOW_OPEN_TABLES]), | ||
| 4552 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4553 | {"show_plugins", | ||
| 4554 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_PLUGINS]), | ||
| 4555 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4556 | {"show_privileges", | ||
| 4557 | (char *)offsetof(System_status_var, | ||
| 4558 | com_stat[(uint)SQLCOM_SHOW_PRIVILEGES]), | ||
| 4559 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4560 | {"show_procedure_code", | ||
| 4561 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_PROC_CODE]), | ||
| 4562 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4563 | {"show_procedure_status", | ||
| 4564 | (char *)offsetof(System_status_var, | ||
| 4565 | com_stat[(uint)SQLCOM_SHOW_STATUS_PROC]), | ||
| 4566 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4567 | {"show_processlist", | ||
| 4568 | (char *)offsetof(System_status_var, | ||
| 4569 | com_stat[(uint)SQLCOM_SHOW_PROCESSLIST]), | ||
| 4570 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4571 | {"show_profile", | ||
| 4572 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_PROFILE]), | ||
| 4573 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4574 | {"show_profiles", | ||
| 4575 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_PROFILES]), | ||
| 4576 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4577 | {"show_relaylog_events", | ||
| 4578 | (char *)offsetof(System_status_var, | ||
| 4579 | com_stat[(uint)SQLCOM_SHOW_RELAYLOG_EVENTS]), | ||
| 4580 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4581 | {"show_replicas", | ||
| 4582 | (char *)offsetof(System_status_var, | ||
| 4583 | com_stat[(uint)SQLCOM_SHOW_SLAVE_HOSTS]), | ||
| 4584 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4585 | {"show_slave_hosts", | ||
| 4586 | (char *)offsetof(System_status_var, | ||
| 4587 | com_stat[(uint)SQLCOM_SHOW_SLAVE_HOSTS]), | ||
| 4588 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4589 | {"show_replica_status", | ||
| 4590 | (char *)offsetof(System_status_var, | ||
| 4591 | com_stat[(uint)SQLCOM_SHOW_SLAVE_STAT]), | ||
| 4592 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4593 | {"show_slave_status", | ||
| 4594 | (char *)offsetof(System_status_var, | ||
| 4595 | com_stat[(uint)SQLCOM_SHOW_SLAVE_STAT]), | ||
| 4596 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4597 | {"show_status", | ||
| 4598 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_STATUS]), | ||
| 4599 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4600 | {"show_storage_engines", | ||
| 4601 | (char *)offsetof(System_status_var, | ||
| 4602 | com_stat[(uint)SQLCOM_SHOW_STORAGE_ENGINES]), | ||
| 4603 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4604 | {"show_table_statistics", | ||
| 4605 | (char *)offsetof(System_status_var, | ||
| 4606 | com_stat[(uint)SQLCOM_SHOW_TABLE_STATS]), | ||
| 4607 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4608 | {"show_table_status", | ||
| 4609 | (char *)offsetof(System_status_var, | ||
| 4610 | com_stat[(uint)SQLCOM_SHOW_TABLE_STATUS]), | ||
| 4611 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4612 | {"show_tables", | ||
| 4613 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_TABLES]), | ||
| 4614 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4615 | {"show_thread_statistics", | ||
| 4616 | (char *)offsetof(System_status_var, | ||
| 4617 | com_stat[(uint)SQLCOM_SHOW_THREAD_STATS]), | ||
| 4618 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4619 | {"show_triggers", | ||
| 4620 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_TRIGGERS]), | ||
| 4621 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4622 | {"show_user_statistics", | ||
| 4623 | (char *)offsetof(System_status_var, | ||
| 4624 | com_stat[(uint)SQLCOM_SHOW_USER_STATS]), | ||
| 4625 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4626 | {"show_variables", | ||
| 4627 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_VARIABLES]), | ||
| 4628 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4629 | {"show_warnings", | ||
| 4630 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHOW_WARNS]), | ||
| 4631 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4632 | {"show_create_user", | ||
| 4633 | (char *)offsetof(System_status_var, | ||
| 4634 | com_stat[(uint)SQLCOM_SHOW_CREATE_USER]), | ||
| 4635 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4636 | {"shutdown", | ||
| 4637 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SHUTDOWN]), | ||
| 4638 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4639 | {"replica_start", | ||
| 4640 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_START]), | ||
| 4641 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4642 | {"slave_start", | ||
| 4643 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_START]), | ||
| 4644 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4645 | {"replica_stop", | ||
| 4646 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_STOP]), | ||
| 4647 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4648 | {"slave_stop", | ||
| 4649 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_SLAVE_STOP]), | ||
| 4650 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4651 | {"group_replication_start", | ||
| 4652 | (char *)offsetof(System_status_var, | ||
| 4653 | com_stat[(uint)SQLCOM_START_GROUP_REPLICATION]), | ||
| 4654 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4655 | {"group_replication_stop", | ||
| 4656 | (char *)offsetof(System_status_var, | ||
| 4657 | com_stat[(uint)SQLCOM_STOP_GROUP_REPLICATION]), | ||
| 4658 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4659 | {"stmt_execute", (char *)offsetof(System_status_var, com_stmt_execute), | ||
| 4660 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4661 | {"stmt_close", (char *)offsetof(System_status_var, com_stmt_close), | ||
| 4662 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4663 | {"stmt_fetch", (char *)offsetof(System_status_var, com_stmt_fetch), | ||
| 4664 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4665 | {"stmt_prepare", (char *)offsetof(System_status_var, com_stmt_prepare), | ||
| 4666 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4667 | {"stmt_reset", (char *)offsetof(System_status_var, com_stmt_reset), | ||
| 4668 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4669 | {"stmt_send_long_data", | ||
| 4670 | (char *)offsetof(System_status_var, com_stmt_send_long_data), | ||
| 4671 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4672 | {"truncate", | ||
| 4673 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_TRUNCATE]), | ||
| 4674 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4675 | {"uninstall_component", | ||
| 4676 | (char *)offsetof(System_status_var, | ||
| 4677 | com_stat[(uint)SQLCOM_UNINSTALL_COMPONENT]), | ||
| 4678 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4679 | {"uninstall_plugin", | ||
| 4680 | (char *)offsetof(System_status_var, | ||
| 4681 | com_stat[(uint)SQLCOM_UNINSTALL_PLUGIN]), | ||
| 4682 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4683 | {"unlock_instance", | ||
| 4684 | (char *)offsetof(System_status_var, | ||
| 4685 | com_stat[(uint)SQLCOM_UNLOCK_INSTANCE]), | ||
| 4686 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4687 | {"unlock_tables", | ||
| 4688 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_UNLOCK_TABLES]), | ||
| 4689 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4690 | {"update", | ||
| 4691 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_UPDATE]), | ||
| 4692 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4693 | {"update_multi", | ||
| 4694 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_UPDATE_MULTI]), | ||
| 4695 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4696 | {"xa_commit", | ||
| 4697 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_COMMIT]), | ||
| 4698 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4699 | {"xa_end", | ||
| 4700 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_END]), | ||
| 4701 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4702 | {"xa_prepare", | ||
| 4703 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_PREPARE]), | ||
| 4704 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4705 | {"xa_recover", | ||
| 4706 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_RECOVER]), | ||
| 4707 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4708 | {"xa_rollback", | ||
| 4709 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_ROLLBACK]), | ||
| 4710 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4711 | {"xa_start", | ||
| 4712 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_XA_START]), | ||
| 4713 | SHOW_LONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 4714 | {NullS, NullS, SHOW_LONG, SHOW_SCOPE_ALL}}; | ||
| 4715 | |||
| 4716 | LEX_CSTRING sql_statement_names[(uint)SQLCOM_END + 1]; | ||
| 4717 | |||
| 4718 | 12109 | static void init_sql_statement_names() { | |
| 4719 | 12109 | char *first_com = (char *)offsetof(System_status_var, com_stat[0]); | |
| 4720 | 12109 | char *last_com = | |
| 4721 | (char *)offsetof(System_status_var, com_stat[(uint)SQLCOM_END]); | ||
| 4722 | 12109 | int record_size = (char *)offsetof(System_status_var, com_stat[1]) - | |
| 4723 | (char *)offsetof(System_status_var, com_stat[0]); | ||
| 4724 | char *ptr; | ||
| 4725 | uint i; | ||
| 4726 | uint com_index; | ||
| 4727 | |||
| 4728 |
2/2✓ Branch 0 taken 2034312 times.
✓ Branch 1 taken 12109 times.
|
2046421 | for (i = 0; i < ((uint)SQLCOM_END + 1); i++) |
| 4729 | 2034312 | sql_statement_names[i] = {STRING_WITH_LEN("")}; | |
| 4730 | |||
| 4731 | 12109 | SHOW_VAR *var = &com_status_vars[0]; | |
| 4732 |
2/2✓ Branch 0 taken 2167511 times.
✓ Branch 1 taken 12109 times.
|
2179620 | while (var->name != nullptr) { |
| 4733 | 2167511 | ptr = var->value; | |
| 4734 |
3/4✓ Branch 0 taken 2082748 times.
✓ Branch 1 taken 84763 times.
✓ Branch 2 taken 2082748 times.
✗ Branch 3 not taken.
|
2167511 | if ((first_com <= ptr) && (ptr <= last_com)) { |
| 4735 | 2082748 | com_index = ((int)(ptr - first_com)) / record_size; | |
| 4736 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2082748 times.
|
2082748 | assert(com_index < (uint)SQLCOM_END); |
| 4737 | 2082748 | sql_statement_names[com_index].str = var->name; | |
| 4738 | /* TODO: Change SHOW_VAR::name to a LEX_STRING, to avoid strlen() */ | ||
| 4739 | 2082748 | sql_statement_names[com_index].length = strlen(var->name); | |
| 4740 | } | ||
| 4741 | 2167511 | var++; | |
| 4742 | } | ||
| 4743 | |||
| 4744 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | assert(strcmp(sql_statement_names[(uint)SQLCOM_SELECT].str, "select") == 0); |
| 4745 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | assert(strcmp(sql_statement_names[(uint)SQLCOM_SIGNAL].str, "signal") == 0); |
| 4746 | |||
| 4747 | 12109 | sql_statement_names[(uint)SQLCOM_END].str = "error"; | |
| 4748 | 12109 | } | |
| 4749 | |||
| 4750 | #ifdef HAVE_PSI_STATEMENT_INTERFACE | ||
| 4751 | PSI_statement_info sql_statement_info[(uint)SQLCOM_END + 1]; | ||
| 4752 | PSI_statement_info com_statement_info[(uint)COM_END + 1]; | ||
| 4753 | |||
| 4754 | /** | ||
| 4755 | Initialize the command names array. | ||
| 4756 | Since we do not want to maintain a separate array, | ||
| 4757 | this is populated from data mined in com_status_vars, | ||
| 4758 | which already has one name for each command. | ||
| 4759 | */ | ||
| 4760 | 12109 | static void init_sql_statement_info() { | |
| 4761 | uint i; | ||
| 4762 | |||
| 4763 |
2/2✓ Branch 0 taken 2034312 times.
✓ Branch 1 taken 12109 times.
|
2046421 | for (i = 0; i < ((uint)SQLCOM_END + 1); i++) { |
| 4764 | 2034312 | sql_statement_info[i].m_name = sql_statement_names[i].str; | |
| 4765 | 2034312 | sql_statement_info[i].m_flags = 0; | |
| 4766 | 2034312 | sql_statement_info[i].m_documentation = PSI_DOCUMENT_ME; | |
| 4767 | } | ||
| 4768 | |||
| 4769 | /* "statement/sql/error" represents broken queries (syntax error). */ | ||
| 4770 | 12109 | sql_statement_info[(uint)SQLCOM_END].m_name = "error"; | |
| 4771 | 12109 | sql_statement_info[(uint)SQLCOM_END].m_flags = 0; | |
| 4772 | 12109 | sql_statement_info[(uint)SQLCOM_END].m_documentation = | |
| 4773 | "Invalid SQL queries (syntax error)."; | ||
| 4774 | |||
| 4775 | /* "statement/sql/clone" will mutate to clone plugin statement */ | ||
| 4776 | 12109 | sql_statement_info[(uint)SQLCOM_CLONE].m_flags = PSI_FLAG_MUTABLE; | |
| 4777 | 12109 | } | |
| 4778 | |||
| 4779 | 12109 | static void init_com_statement_info() { | |
| 4780 | uint index; | ||
| 4781 | |||
| 4782 |
2/2✓ Branch 0 taken 423815 times.
✓ Branch 1 taken 12109 times.
|
435924 | for (index = 0; index < (uint)COM_END + 1; index++) { |
| 4783 | 423815 | com_statement_info[index].m_name = | |
| 4784 | 423815 | Command_names::str_notranslate(index).c_str(); | |
| 4785 | 423815 | com_statement_info[index].m_flags = 0; | |
| 4786 | 423815 | com_statement_info[index].m_documentation = PSI_DOCUMENT_ME; | |
| 4787 | } | ||
| 4788 | |||
| 4789 | /* "statement/abstract/query" can mutate into "statement/sql/..." */ | ||
| 4790 | 12109 | com_statement_info[(uint)COM_QUERY].m_flags = PSI_FLAG_MUTABLE; | |
| 4791 | 12109 | com_statement_info[(uint)COM_QUERY].m_documentation = | |
| 4792 | "SQL query just received from the network. " | ||
| 4793 | "At this point, the real statement type is unknown, " | ||
| 4794 | "the type will be refined after SQL parsing."; | ||
| 4795 | |||
| 4796 | /* "statement/com/clone" will mutate to clone plugin statement */ | ||
| 4797 | 12109 | com_statement_info[(uint)COM_CLONE].m_flags = PSI_FLAG_MUTABLE; | |
| 4798 | 12109 | } | |
| 4799 | #endif | ||
| 4800 | |||
| 4801 | /** | ||
| 4802 | Parse @@authentication_policy variable value. | ||
| 4803 | |||
| 4804 | @param [in] val Buffer holding variable value. | ||
| 4805 | @param [out] policy_list Vector holding the parsed values. | ||
| 4806 | |||
| 4807 | @retval false OK | ||
| 4808 | @retval true Error | ||
| 4809 | */ | ||
| 4810 | 23388 | bool parse_authentication_policy(char *val, | |
| 4811 | std::vector<std::string> &policy_list) { | ||
| 4812 | 23388 | std::string token; | |
| 4813 |
1/2✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
|
23388 | std::string policy_val(val); |
| 4814 |
2/4✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23388 times.
✗ Branch 3 not taken.
|
46776 | std::stringstream policy_str(val); |
| 4815 | 23388 | bool is_empty = false; | |
| 4816 | /* count comma */ | ||
| 4817 |
1/2✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
|
23388 | size_t comma_cnt = std::count(policy_val.begin(), policy_val.end(), ','); |
| 4818 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23388 times.
|
23388 | if (comma_cnt >= MAX_AUTH_FACTORS) return true; |
| 4819 | /* | ||
| 4820 | While parsing ensure that an empty value which means an optional nth factor, | ||
| 4821 | should be followed with an empty value only. | ||
| 4822 | Below are some invalid values: | ||
| 4823 | 'caching_sha2_password,,authentication_fido' | ||
| 4824 | ',authentication_fido,authentication_ldap_simple' | ||
| 4825 | ',authentication_fido,' | ||
| 4826 | ',,' | ||
| 4827 | */ | ||
| 4828 |
4/6✓ Branch 0 taken 70164 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70164 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 46776 times.
✓ Branch 5 taken 23388 times.
|
70164 | while (getline(policy_str, token, ',')) { |
| 4829 |
1/2✓ Branch 0 taken 46776 times.
✗ Branch 1 not taken.
|
46776 | std::string s(token); |
| 4830 | /* trim spaces */ | ||
| 4831 |
2/4✓ Branch 0 taken 46776 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46776 times.
✗ Branch 3 not taken.
|
46776 | s.erase(std::remove(s.begin(), s.end(), ' '), s.end()); |
| 4832 |
4/6✓ Branch 0 taken 23388 times.
✓ Branch 1 taken 23388 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23388 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 46776 times.
|
46776 | if (s.length() && is_empty) { |
| 4833 | ✗ | policy_list.clear(); | |
| 4834 | ✗ | return true; | |
| 4835 | }; | ||
| 4836 |
2/2✓ Branch 0 taken 23388 times.
✓ Branch 1 taken 23388 times.
|
46776 | if (!s.length()) is_empty = true; |
| 4837 |
1/2✓ Branch 0 taken 46776 times.
✗ Branch 1 not taken.
|
46776 | policy_list.push_back(s); |
| 4838 |
1/2✓ Branch 0 taken 46776 times.
✗ Branch 1 not taken.
|
46776 | } |
| 4839 | /* | ||
| 4840 | Values like 'caching_sha2_password,authentication_fido,' or | ||
| 4841 | 'caching_sha2_password,,' will not capture the last empty value, thus append | ||
| 4842 | an empty value to the list. | ||
| 4843 | */ | ||
| 4844 |
3/6✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23388 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23388 times.
✗ Branch 5 not taken.
|
46776 | if ((comma_cnt == policy_list.size()) && |
| 4845 | 23388 | policy_list.size() < MAX_AUTH_FACTORS) | |
| 4846 |
2/4✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23388 times.
✗ Branch 3 not taken.
|
23388 | policy_list.push_back(""); |
| 4847 | |||
| 4848 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23388 times.
|
23388 | if (policy_list.size() > MAX_AUTH_FACTORS) { |
| 4849 | ✗ | policy_list.clear(); | |
| 4850 | ✗ | return true; | |
| 4851 | } | ||
| 4852 | 23388 | return false; | |
| 4853 | 23388 | } | |
| 4854 | |||
| 4855 | /** | ||
| 4856 | Validate @@authentication_policy variable value. | ||
| 4857 | |||
| 4858 | @param [in] val Buffer holding variable value. | ||
| 4859 | |||
| 4860 | @retval false success | ||
| 4861 | @retval true failure | ||
| 4862 | */ | ||
| 4863 | 11694 | bool validate_authentication_policy(char *val) { | |
| 4864 | 11694 | std::vector<std::string> list; | |
| 4865 |
2/4✓ Branch 0 taken 11694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11694 times.
|
11694 | if (parse_authentication_policy(val, list)) return true; |
| 4866 |
2/2✓ Branch 0 taken 35082 times.
✓ Branch 1 taken 11694 times.
|
46776 | for (auto it = list.begin(); it != list.end(); it++) { |
| 4867 | /* plugin name in first place holder cannot be empty */ | ||
| 4868 |
2/2✓ Branch 0 taken 23388 times.
✓ Branch 1 taken 11694 times.
|
35082 | if (!it->length()) { |
| 4869 |
3/6✓ Branch 0 taken 23388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23388 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 23388 times.
|
23388 | if (list.size() == 1 || it == list.begin()) return true; |
| 4870 | } | ||
| 4871 | /* skip special characters like * and <empty> string */ | ||
| 4872 |
2/2✓ Branch 0 taken 23388 times.
✓ Branch 1 taken 11694 times.
|
46776 | if (!it->length()) continue; |
| 4873 |
1/2✓ Branch 0 taken 11694 times.
✗ Branch 1 not taken.
|
11694 | if (!it->compare("*")) continue; |
| 4874 | /* validate plugin name */ | ||
| 4875 | ✗ | plugin_ref p = my_plugin_lock_by_name(nullptr, to_lex_cstring(it->c_str()), | |
| 4876 | MYSQL_AUTHENTICATION_PLUGIN); | ||
| 4877 | ✗ | if (!p) goto error; | |
| 4878 | ✗ | st_mysql_auth *auth = (st_mysql_auth *)plugin_decl(p)->info; | |
| 4879 | /* | ||
| 4880 | ensure 2nd and 3rd factor auth plugins which store password in mysql | ||
| 4881 | server are not allowed. | ||
| 4882 | */ | ||
| 4883 | ✗ | if (it != list.begin() && | |
| 4884 | ✗ | auth->authentication_flags & AUTH_FLAG_USES_INTERNAL_STORAGE) { | |
| 4885 | ✗ | authentication_policy_plugin_ref.push_back(p); | |
| 4886 | ✗ | goto error; | |
| 4887 | } | ||
| 4888 | /* | ||
| 4889 | ensure plugin name in first place holder cannot be auth plugin | ||
| 4890 | which requires registration step. | ||
| 4891 | */ | ||
| 4892 | ✗ | if (it == list.begin() && | |
| 4893 | ✗ | auth->authentication_flags & AUTH_FLAG_REQUIRES_REGISTRATION) { | |
| 4894 | ✗ | authentication_policy_plugin_ref.push_back(p); | |
| 4895 | ✗ | goto error; | |
| 4896 | } | ||
| 4897 | ✗ | authentication_policy_plugin_ref.push_back(p); | |
| 4898 | } | ||
| 4899 | 11694 | return false; | |
| 4900 | ✗ | error: | |
| 4901 | ✗ | for (auto p : authentication_policy_plugin_ref) plugin_unlock(nullptr, p); | |
| 4902 | ✗ | authentication_policy_plugin_ref.clear(); | |
| 4903 | ✗ | return true; | |
| 4904 | 11694 | } | |
| 4905 | |||
| 4906 | /** | ||
| 4907 | Update @@authentication_policy variable value. | ||
| 4908 | |||
| 4909 | @retval false success | ||
| 4910 | @retval true failure | ||
| 4911 | */ | ||
| 4912 | 11694 | bool update_authentication_policy() { | |
| 4913 | 11694 | std::vector<std::string> list; | |
| 4914 |
2/4✓ Branch 0 taken 11694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11694 times.
|
11694 | if (parse_authentication_policy(opt_authentication_policy, list)) return true; |
| 4915 | /* update the actual policy list only after validation is successful */ | ||
| 4916 |
1/2✓ Branch 0 taken 11694 times.
✗ Branch 1 not taken.
|
11694 | authentication_policy_list = list; |
| 4917 | /* release plugin reference */ | ||
| 4918 |
1/4✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11694 times.
|
11694 | for (auto p : authentication_policy_plugin_ref) plugin_unlock(nullptr, p); |
| 4919 | 11694 | authentication_policy_plugin_ref.clear(); | |
| 4920 | 11694 | return false; | |
| 4921 | 11694 | } | |
| 4922 | /** | ||
| 4923 | Create a replication file name or base for file names. | ||
| 4924 | |||
| 4925 | @param key Instrumentation key used to track allocations | ||
| 4926 | @param[in] opt Value of option, or NULL | ||
| 4927 | @param[in] def Default value if option value is not set. | ||
| 4928 | @param[in] ext Extension to use for the path | ||
| 4929 | |||
| 4930 | @returns Pointer to string containing the full file path, or NULL if | ||
| 4931 | it was not possible to create the path. | ||
| 4932 | */ | ||
| 4933 | 47004 | static inline const char *rpl_make_log_name(PSI_memory_key key, const char *opt, | |
| 4934 | const char *def, const char *ext) { | ||
| 4935 |
1/2✓ Branch 0 taken 47004 times.
✗ Branch 1 not taken.
|
47004 | DBUG_TRACE; |
| 4936 |
3/12✓ Branch 0 taken 47004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47004 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 47004 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
|
47004 | DBUG_PRINT("enter", ("opt: %s, def: %s, ext: %s", (opt && opt[0]) ? opt : "", |
| 4937 | def, ext)); | ||
| 4938 | char buff[FN_REFLEN]; | ||
| 4939 | /* | ||
| 4940 | opt[0] needs to be checked to make sure opt name is not an empty | ||
| 4941 | string, in case it is an empty string default name will be considered | ||
| 4942 | */ | ||
| 4943 |
3/4✓ Branch 0 taken 14641 times.
✓ Branch 1 taken 32363 times.
✓ Branch 2 taken 14641 times.
✗ Branch 3 not taken.
|
47004 | const char *base = (opt && opt[0]) ? opt : def; |
| 4944 | 47004 | unsigned int options = MY_REPLACE_EXT | MY_UNPACK_FILENAME | MY_SAFE_PATH; | |
| 4945 | |||
| 4946 | /* mysql_real_data_home_ptr may be null if no value of datadir has been | ||
| 4947 | specified through command-line or througha cnf file. If that is the | ||
| 4948 | case we make mysql_real_data_home_ptr point to mysql_real_data_home | ||
| 4949 | which, in that case holds the default path for data-dir. | ||
| 4950 | */ | ||
| 4951 | |||
| 4952 |
3/4✓ Branch 0 taken 47004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 47000 times.
|
47004 | DBUG_EXECUTE_IF("emulate_empty_datadir_param", |
| 4953 | { mysql_real_data_home_ptr = nullptr; };); | ||
| 4954 | |||
| 4955 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 47000 times.
|
47004 | if (mysql_real_data_home_ptr == nullptr) |
| 4956 | 4 | mysql_real_data_home_ptr = mysql_real_data_home; | |
| 4957 | |||
| 4958 |
2/4✓ Branch 0 taken 47004 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47004 times.
✗ Branch 3 not taken.
|
47004 | if (fn_format(buff, base, mysql_real_data_home_ptr, ext, options)) |
| 4959 |
1/2✓ Branch 0 taken 47004 times.
✗ Branch 1 not taken.
|
47004 | return my_strdup(key, buff, MYF(0)); |
| 4960 | else | ||
| 4961 | ✗ | return nullptr; | |
| 4962 | 47004 | } | |
| 4963 | |||
| 4964 | 12142 | int init_common_variables() { | |
| 4965 | 12142 | my_decimal_set_zero(&decimal_zero); // set decimal_zero constant; | |
| 4966 | 12142 | tzset(); // Set tzname | |
| 4967 | |||
| 4968 | 12142 | max_system_variables.pseudo_thread_id = (my_thread_id)~0; | |
| 4969 | 12142 | server_start_time = flush_status_time = time(nullptr); | |
| 4970 | |||
| 4971 |
1/2✓ Branch 0 taken 12142 times.
✗ Branch 1 not taken.
|
12142 | binlog_filter = new Rpl_filter; |
| 4972 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12142 times.
|
12142 | if (!binlog_filter) { |
| 4973 | ✗ | LogErr(ERROR_LEVEL, ER_RPL_BINLOG_FILTERS_OOM, strerror(errno)); | |
| 4974 | ✗ | return 1; | |
| 4975 | } | ||
| 4976 | |||
| 4977 |
3/6✓ Branch 0 taken 12142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12142 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12142 times.
|
12142 | if (init_thread_environment() || mysql_init_variables()) return 1; |
| 4978 | |||
| 4979 | { | ||
| 4980 | #ifdef _WIN32 | ||
| 4981 | strmake(system_time_zone_dst_off, _tzname[0], | ||
| 4982 | sizeof(system_time_zone_dst_off) - 1); | ||
| 4983 | strmake(system_time_zone_dst_on, _tzname[1], | ||
| 4984 | sizeof(system_time_zone_dst_on) - 1); | ||
| 4985 | #else | ||
| 4986 | 12142 | strmake(system_time_zone_dst_off, tzname[0], | |
| 4987 | sizeof(system_time_zone_dst_off) - 1); | ||
| 4988 | 12142 | strmake(system_time_zone_dst_on, tzname[1], | |
| 4989 | sizeof(system_time_zone_dst_on) - 1); | ||
| 4990 | #endif | ||
| 4991 | } | ||
| 4992 | /* | ||
| 4993 | We set SYSTEM time zone as reasonable default and | ||
| 4994 | also for failure of my_tz_init() and bootstrap mode. | ||
| 4995 | If user explicitly set time zone with --default-time-zone | ||
| 4996 | option we will change this value in my_tz_init(). | ||
| 4997 | */ | ||
| 4998 | 12142 | global_system_variables.time_zone = my_tz_SYSTEM; | |
| 4999 | |||
| 5000 | #ifdef HAVE_PSI_INTERFACE | ||
| 5001 | /* | ||
| 5002 | Complete the mysql_bin_log initialization. | ||
| 5003 | Instrumentation keys are known only after the performance schema | ||
| 5004 | initialization, and can not be set in the MYSQL_BIN_LOG constructor (called | ||
| 5005 | before main()). | ||
| 5006 | */ | ||
| 5007 | 12142 | mysql_bin_log.set_psi_keys( | |
| 5008 | key_BINLOG_LOCK_index, key_BINLOG_LOCK_commit, | ||
| 5009 | key_BINLOG_LOCK_commit_queue, key_BINLOG_LOCK_done, | ||
| 5010 | key_BINLOG_LOCK_flush_queue, key_BINLOG_LOCK_log, | ||
| 5011 | key_BINLOG_LOCK_binlog_end_pos, key_BINLOG_LOCK_sync, | ||
| 5012 | key_BINLOG_LOCK_sync_queue, key_BINLOG_LOCK_xids, key_BINLOG_COND_done, | ||
| 5013 | key_BINLOG_COND_flush_queue, key_BINLOG_update_cond, | ||
| 5014 | key_BINLOG_prep_xids_cond, key_file_binlog, key_file_binlog_index, | ||
| 5015 | key_file_binlog_cache, key_file_binlog_index_cache); | ||
| 5016 | #endif | ||
| 5017 | |||
| 5018 | /* | ||
| 5019 | Init mutexes for the global MYSQL_BIN_LOG objects. | ||
| 5020 | As safe_mutex depends on what MY_INIT() does, we can't init the mutexes of | ||
| 5021 | global MYSQL_BIN_LOGs in their constructors, because then they would be | ||
| 5022 | inited before MY_INIT(). So we do it here. | ||
| 5023 | */ | ||
| 5024 | 12142 | mysql_bin_log.init_pthread_objects(); | |
| 5025 | |||
| 5026 | /* TODO: remove this when my_time_t is 64 bit compatible */ | ||
| 5027 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12142 times.
|
12142 | if (!is_time_t_valid_for_timestamp(server_start_time)) { |
| 5028 | ✗ | LogErr(ERROR_LEVEL, ER_UNSUPPORTED_DATE); | |
| 5029 | ✗ | return 1; | |
| 5030 | } | ||
| 5031 | |||
| 5032 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12142 times.
|
12142 | if (gethostname(glob_hostname, sizeof(glob_hostname)) < 0) { |
| 5033 | ✗ | strmake(glob_hostname, STRING_WITH_LEN("localhost")); | |
| 5034 | ✗ | LogErr(WARNING_LEVEL, ER_CALL_ME_LOCALHOST, glob_hostname); | |
| 5035 | ✗ | strmake(default_logfile_name, STRING_WITH_LEN("mysql")); | |
| 5036 | } else | ||
| 5037 | 12142 | strmake(default_logfile_name, glob_hostname, | |
| 5038 | sizeof(default_logfile_name) - 5); | ||
| 5039 | |||
| 5040 | 12142 | strmake(default_binlogfile_name, STRING_WITH_LEN("binlog")); | |
| 5041 |
3/4✓ Branch 0 taken 11841 times.
✓ Branch 1 taken 301 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11841 times.
|
12142 | if (opt_initialize || opt_initialize_insecure) { |
| 5042 | /* | ||
| 5043 | System tables initialization are not binary logged (regardless | ||
| 5044 | --log-bin option). | ||
| 5045 | |||
| 5046 | Disable binary log while executing any user script sourced while | ||
| 5047 | initializing system except if explicitly requested. | ||
| 5048 | */ | ||
| 5049 | 301 | opt_bin_log = false; | |
| 5050 | } | ||
| 5051 | |||
| 5052 | 12142 | strmake(pidfile_name, default_logfile_name, sizeof(pidfile_name) - 5); | |
| 5053 | 12142 | my_stpcpy(fn_ext(pidfile_name), ".pid"); // Add proper extension | |
| 5054 | |||
| 5055 | /* | ||
| 5056 | The default-storage-engine entry in my_long_options should have a | ||
| 5057 | non-null default value. It was earlier initialized as | ||
| 5058 | (longlong)"MyISAM" in my_long_options but this triggered a | ||
| 5059 | compiler error in the Sun Studio 12 compiler. As a work-around we | ||
| 5060 | set the def_value member to 0 in my_long_options and initialize it | ||
| 5061 | to the correct value here. | ||
| 5062 | |||
| 5063 | From MySQL 5.5 onwards, the default storage engine is InnoDB. | ||
| 5064 | */ | ||
| 5065 | 12142 | default_storage_engine = "InnoDB"; | |
| 5066 | 12142 | default_tmp_storage_engine = default_storage_engine; | |
| 5067 | |||
| 5068 | /* | ||
| 5069 | Add server status variables to the dynamic list of | ||
| 5070 | status variables that is shown by SHOW STATUS. | ||
| 5071 | Later, in plugin_register_builtin_and_init_core_se(), | ||
| 5072 | plugin_register_dynamic_and_init_all() and | ||
| 5073 | mysql_install_plugin(), new entries could be added | ||
| 5074 | to that list. | ||
| 5075 | */ | ||
| 5076 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12142 times.
|
12142 | if (add_status_vars(status_vars)) return 1; // an error was already reported |
| 5077 | |||
| 5078 | #ifndef NDEBUG | ||
| 5079 | /* | ||
| 5080 | We have few debug-only commands in com_status_vars, only visible in debug | ||
| 5081 | builds. for simplicity we enable the assert only in debug builds | ||
| 5082 | |||
| 5083 | There are 8 Com_ variables which don't have corresponding SQLCOM_ values: | ||
| 5084 | (TODO strictly speaking they shouldn't be here, should not have Com_ prefix | ||
| 5085 | that is. Perhaps Stmt_ ? Comstmt_ ? Prepstmt_ ?) | ||
| 5086 | |||
| 5087 | Com_admin_commands => com_other | ||
| 5088 | Com_stmt_close => com_stmt_close | ||
| 5089 | Com_stmt_execute => com_stmt_execute | ||
| 5090 | Com_stmt_fetch => com_stmt_fetch | ||
| 5091 | Com_stmt_prepare => com_stmt_prepare | ||
| 5092 | Com_stmt_reprepare => com_stmt_reprepare | ||
| 5093 | Com_stmt_reset => com_stmt_reset | ||
| 5094 | Com_stmt_send_long_data => com_stmt_send_long_data | ||
| 5095 | |||
| 5096 | We also have aliases for 5 com_status_vars: | ||
| 5097 | |||
| 5098 | Com_slave_start => Com_replica_start | ||
| 5099 | Com_slave_stop => Com_replica_stop | ||
| 5100 | Com_show_slave_status => Com_show_replica_status | ||
| 5101 | Com_show_slave_hosts => Com_show_replicas | ||
| 5102 | Com_change_master => Com_change_replication_source | ||
| 5103 | |||
| 5104 | With this correction the number of Com_ variables (number of elements in | ||
| 5105 | the array, excluding the last element - terminator) must match the number | ||
| 5106 | of SQLCOM_ constants. | ||
| 5107 | */ | ||
| 5108 | static_assert(sizeof(com_status_vars) / sizeof(com_status_vars[0]) - 1 == | ||
| 5109 | SQLCOM_END + 12, | ||
| 5110 | ""); | ||
| 5111 | #endif | ||
| 5112 | |||
| 5113 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 12108 times.
|
12142 | if (get_options(&remaining_argc, &remaining_argv)) return 1; |
| 5114 | |||
| 5115 | /* | ||
| 5116 | The opt_bin_log can be false (binary log is disabled) only if | ||
| 5117 | --skip-log-bin/--disable-log-bin is configured or while the | ||
| 5118 | system is initializing. | ||
| 5119 | */ | ||
| 5120 |
2/2✓ Branch 0 taken 614 times.
✓ Branch 1 taken 11494 times.
|
12108 | if (!opt_bin_log) { |
| 5121 | /* | ||
| 5122 | The log-replica-updates should be disabled if binary log is disabled | ||
| 5123 | and --log-replica-updates option is not set explicitly on command | ||
| 5124 | line or configuration file. | ||
| 5125 | */ | ||
| 5126 |
2/2✓ Branch 0 taken 425 times.
✓ Branch 1 taken 189 times.
|
614 | if (!log_replica_updates_supplied) opt_log_replica_updates = false; |
| 5127 | } | ||
| 5128 | |||
| 5129 |
1/2✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
|
12108 | if (opt_protocol_compression_algorithms) { |
| 5130 |
1/2✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
|
24216 | if ((opt_protocol_compression_algorithms[0] == 0) || |
| 5131 |
3/4✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12107 times.
|
12108 | (validate_compression_attributes( |
| 5132 |
6/16✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12108 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12108 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✓ Branch 9 taken 12107 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
|
24216 | std::string(opt_protocol_compression_algorithms), std::string(), |
| 5133 | true))) { | ||
| 5134 | /* | ||
| 5135 | --protocol-compression-algorithms is set to invalid value, resetting | ||
| 5136 | its value to default "zlib,zstd,uncompressed" | ||
| 5137 | */ | ||
| 5138 | 1 | opt_protocol_compression_algorithms = | |
| 5139 | const_cast<char *>(PROTOCOL_COMPRESSION_DEFAULT_VALUE); | ||
| 5140 |
7/14✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
|
1 | LogErr(WARNING_LEVEL, ER_PROTOCOL_COMPRESSION_RESET_LOG); |
| 5141 | } | ||
| 5142 | } | ||
| 5143 | 12108 | update_parser_max_mem_size(); | |
| 5144 | |||
| 5145 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | if (set_default_auth_plugin(default_auth_plugin, |
| 5146 | strlen(default_auth_plugin))) { | ||
| 5147 | ✗ | LogErr(ERROR_LEVEL, ER_AUTH_CANT_SET_DEFAULT_PLUGIN); | |
| 5148 | ✗ | return 1; | |
| 5149 | } | ||
| 5150 | 12108 | set_server_version(); | |
| 5151 | |||
| 5152 |
2/2✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 18 times.
|
12108 | if (!is_help_or_validate_option()) { |
| 5153 |
7/14✓ Branch 0 taken 12090 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12090 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12090 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12090 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12090 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12090 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12090 times.
✗ Branch 13 not taken.
|
12090 | LogErr(INFORMATION_LEVEL, ER_BASEDIR_SET_TO, mysql_home); |
| 5154 | } | ||
| 5155 |
5/6✓ Branch 0 taken 12103 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 11802 times.
✓ Branch 3 taken 301 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 11802 times.
|
12108 | if (!opt_validate_config && (opt_initialize || opt_initialize_insecure)) { |
| 5156 |
7/14✓ Branch 0 taken 301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 301 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 301 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 301 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 301 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 301 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 301 times.
✗ Branch 13 not taken.
|
301 | LogErr(SYSTEM_LEVEL, ER_STARTING_INIT, my_progname, server_version, |
| 5157 | (ulong)getpid()); | ||
| 5158 |
2/2✓ Branch 0 taken 11790 times.
✓ Branch 1 taken 17 times.
|
11807 | } else if (!is_help_or_validate_option()) { |
| 5159 |
7/14✓ Branch 0 taken 11790 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11790 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11790 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11790 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11790 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11790 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11790 times.
✗ Branch 13 not taken.
|
11790 | LogErr(SYSTEM_LEVEL, ER_STARTING_AS, my_progname, server_version, |
| 5160 | (ulong)getpid()); | ||
| 5161 | } | ||
| 5162 |
3/4✓ Branch 0 taken 13 times.
✓ Branch 1 taken 12095 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
|
12108 | if (opt_help && !opt_verbose) unireg_abort(MYSQLD_SUCCESS_EXIT); |
| 5163 | |||
| 5164 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | DBUG_PRINT("info", ("%s Ver %s for %s on %s\n", my_progname, server_version, |
| 5165 | SYSTEM_TYPE, MACHINE_TYPE)); | ||
| 5166 | |||
| 5167 | #ifdef HAVE_LINUX_LARGE_PAGES | ||
| 5168 | /* Initialize large page size */ | ||
| 5169 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12108 times.
|
12108 | if (opt_large_pages && (opt_large_page_size = my_get_large_page_size())) { |
| 5170 | ✗ | DBUG_PRINT("info", | |
| 5171 | ("Large page set, large_page_size = %d", opt_large_page_size)); | ||
| 5172 | } else { | ||
| 5173 | 12108 | opt_large_pages = false; | |
| 5174 | /* | ||
| 5175 | Either not configured to use large pages or Linux haven't | ||
| 5176 | been compiled with large page support | ||
| 5177 | */ | ||
| 5178 | } | ||
| 5179 | #endif /* HAVE_LINUX_LARGE_PAGES */ | ||
| 5180 | #ifdef HAVE_SOLARIS_LARGE_PAGES | ||
| 5181 | #define LARGE_PAGESIZE (4 * 1024 * 1024) /* 4MB */ | ||
| 5182 | #define SUPER_LARGE_PAGESIZE (256 * 1024 * 1024) /* 256MB */ | ||
| 5183 | if (opt_large_pages) { | ||
| 5184 | /* | ||
| 5185 | tell the kernel that we want to use 4/256MB page for heap storage | ||
| 5186 | and also for the stack. We use 4 MByte as default and if the | ||
| 5187 | super-large-page is set we increase it to 256 MByte. 256 MByte | ||
| 5188 | is for server installations with GBytes of RAM memory where | ||
| 5189 | the MySQL Server will have page caches and other memory regions | ||
| 5190 | measured in a number of GBytes. | ||
| 5191 | We use as big pages as possible which isn't bigger than the above | ||
| 5192 | desired page sizes. | ||
| 5193 | */ | ||
| 5194 | int nelem; | ||
| 5195 | size_t max_desired_page_size; | ||
| 5196 | if (opt_super_large_pages) | ||
| 5197 | max_desired_page_size = SUPER_LARGE_PAGESIZE; | ||
| 5198 | else | ||
| 5199 | max_desired_page_size = LARGE_PAGESIZE; | ||
| 5200 | nelem = getpagesizes(NULL, 0); | ||
| 5201 | if (nelem > 0) { | ||
| 5202 | size_t *pagesize = (size_t *)malloc(sizeof(size_t) * nelem); | ||
| 5203 | if (pagesize != NULL && getpagesizes(pagesize, nelem) > 0) { | ||
| 5204 | size_t max_page_size = 0; | ||
| 5205 | for (int i = 0; i < nelem; i++) { | ||
| 5206 | if (pagesize[i] > max_page_size && | ||
| 5207 | pagesize[i] <= max_desired_page_size) | ||
| 5208 | max_page_size = pagesize[i]; | ||
| 5209 | } | ||
| 5210 | free(pagesize); | ||
| 5211 | if (max_page_size > 0) { | ||
| 5212 | struct memcntl_mha mpss; | ||
| 5213 | |||
| 5214 | mpss.mha_cmd = MHA_MAPSIZE_BSSBRK; | ||
| 5215 | mpss.mha_pagesize = max_page_size; | ||
| 5216 | mpss.mha_flags = 0; | ||
| 5217 | memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mpss, 0, 0); | ||
| 5218 | mpss.mha_cmd = MHA_MAPSIZE_STACK; | ||
| 5219 | memcntl(NULL, 0, MC_HAT_ADVISE, (caddr_t)&mpss, 0, 0); | ||
| 5220 | } | ||
| 5221 | } | ||
| 5222 | } | ||
| 5223 | } | ||
| 5224 | #endif /* HAVE_SOLARIS_LARGE_PAGES */ | ||
| 5225 | |||
| 5226 | longlong default_value; | ||
| 5227 | sys_var *var; | ||
| 5228 | /* Calculate and update default value for thread_cache_size. */ | ||
| 5229 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | if ((default_value = 8 + max_connections / 100) > 100) default_value = 100; |
| 5230 |
2/4✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12108 times.
✗ Branch 3 not taken.
|
12108 | var = find_static_system_variable("thread_cache_size"); |
| 5231 | 12108 | var->update_default(default_value); | |
| 5232 | |||
| 5233 | /* Calculate and update default value for host_cache_size. */ | ||
| 5234 |
3/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12107 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12108 times.
|
12109 | if ((default_value = 128 + max_connections) > 628 && |
| 5235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | (default_value = 628 + ((max_connections - 500) / 20)) > 2000) |
| 5236 | ✗ | default_value = 2000; | |
| 5237 |
2/4✓ Branch 0 taken 12108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12108 times.
✗ Branch 3 not taken.
|
12108 | var = find_static_system_variable("host_cache_size"); |
| 5238 | 12108 | var->update_default(default_value); | |
| 5239 | |||
| 5240 | /* Fix thread_cache_size. */ | ||
| 5241 |
3/4✓ Branch 0 taken 12106 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12108 times.
|
24214 | if (!thread_cache_size_specified && |
| 5242 | 12106 | (Per_thread_connection_handler::max_blocked_pthreads = | |
| 5243 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12106 times.
|
12106 | 8 + max_connections / 100) > 100) |
| 5244 | ✗ | Per_thread_connection_handler::max_blocked_pthreads = 100; | |
| 5245 | |||
| 5246 | /* Fix host_cache_size. */ | ||
| 5247 | 36322 | if (!host_cache_size_specified && | |
| 5248 |
5/6✓ Branch 0 taken 12106 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12108 times.
|
12109 | (host_cache_size = 128 + max_connections) > 628 && |
| 5249 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | (host_cache_size = 628 + ((max_connections - 500) / 20)) > 2000) |
| 5250 | ✗ | host_cache_size = 2000; | |
| 5251 | |||
| 5252 | /* Fix back_log */ | ||
| 5253 |
4/6✓ Branch 0 taken 12105 times.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12105 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 12108 times.
|
12108 | if (back_log == 0 && (back_log = max_connections) > 65535) back_log = 65535; |
| 5254 | |||
| 5255 | 12108 | unireg_init(opt_specialflag); /* Set up extern variables */ | |
| 5256 | 12108 | while (!(my_default_lc_messages = | |
| 5257 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12108 times.
|
12110 | my_locale_by_name(nullptr, lc_messages, strlen(lc_messages)))) { |
| 5258 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | LogErr(ERROR_LEVEL, ER_FAILED_TO_FIND_LOCALE_NAME, lc_messages); |
| 5259 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!my_strcasecmp(&my_charset_latin1, lc_messages, |
| 5260 | mysqld_default_locale_name)) | ||
| 5261 | ✗ | return 1; | |
| 5262 | 2 | lc_messages = mysqld_default_locale_name; | |
| 5263 | } | ||
| 5264 | 12108 | global_system_variables.lc_messages = my_default_lc_messages; | |
| 5265 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | if (init_errmessage()) /* Read error messages from file */ |
| 5266 | ✗ | return 1; | |
| 5267 | 12108 | init_client_errs(); | |
| 5268 | |||
| 5269 | 12108 | mysql_client_plugin_init(); | |
| 5270 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | if (item_create_init()) return 1; |
| 5271 | 12108 | item_init(); | |
| 5272 | 12108 | range_optimizer_init(); | |
| 5273 | 12108 | my_string_stack_guard = check_enough_stack_size; | |
| 5274 | /* | ||
| 5275 | Process a comma-separated character set list and choose | ||
| 5276 | the first available character set. This is mostly for | ||
| 5277 | test purposes, to be able to start "mysqld" even if | ||
| 5278 | the requested character set is not available (see bug#18743). | ||
| 5279 | */ | ||
| 5280 | for (;;) { | ||
| 5281 | char *next_character_set_name = | ||
| 5282 | 12108 | strchr(const_cast<char *>(default_character_set_name), ','); | |
| 5283 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12106 times.
|
12108 | if (next_character_set_name) *next_character_set_name++ = '\0'; |
| 5284 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12107 times.
|
12108 | if (!(default_charset_info = get_charset_by_csname( |
| 5285 | default_character_set_name, MY_CS_PRIMARY, MYF(MY_WME)))) { | ||
| 5286 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | if (next_character_set_name) { |
| 5287 | ✗ | default_character_set_name = next_character_set_name; | |
| 5288 | ✗ | default_collation_name = nullptr; // Ignore collation | |
| 5289 | } else | ||
| 5290 | 1 | return 1; // Eof of the list | |
| 5291 | } else { | ||
| 5292 | 12107 | warn_on_deprecated_charset(nullptr, default_charset_info, | |
| 5293 | default_character_set_name, | ||
| 5294 | "--character-set-server"); | ||
| 5295 | 12107 | break; | |
| 5296 | } | ||
| 5297 | } | ||
| 5298 | |||
| 5299 |
2/2✓ Branch 0 taken 12088 times.
✓ Branch 1 taken 19 times.
|
12107 | if (default_collation_name) { |
| 5300 | CHARSET_INFO *default_collation; | ||
| 5301 | 12088 | default_collation = get_charset_by_name(default_collation_name, MYF(0)); | |
| 5302 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12088 times.
|
12088 | if (!default_collation) { |
| 5303 | ✗ | LogErr(ERROR_LEVEL, ER_FAILED_TO_FIND_COLLATION_NAME, | |
| 5304 | default_collation_name); | ||
| 5305 | ✗ | return 1; | |
| 5306 | } | ||
| 5307 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12088 times.
|
12088 | if (!my_charset_same(default_charset_info, default_collation)) { |
| 5308 | ✗ | LogErr(ERROR_LEVEL, ER_INVALID_COLLATION_FOR_CHARSET, | |
| 5309 | default_collation_name, default_charset_info->csname); | ||
| 5310 | ✗ | return 1; | |
| 5311 | } | ||
| 5312 | 12088 | warn_on_deprecated_collation(nullptr, default_collation, | |
| 5313 | "--collation-server"); | ||
| 5314 | 12088 | default_charset_info = default_collation; | |
| 5315 | } | ||
| 5316 | /* Set collactions that depends on the default collation */ | ||
| 5317 | 12107 | global_system_variables.collation_server = default_charset_info; | |
| 5318 | 12107 | global_system_variables.collation_database = default_charset_info; | |
| 5319 | 12107 | global_system_variables.default_collation_for_utf8mb4 = | |
| 5320 | &my_charset_utf8mb4_0900_ai_ci; | ||
| 5321 | |||
| 5322 |
2/2✓ Branch 0 taken 12093 times.
✓ Branch 1 taken 14 times.
|
12107 | if (is_supported_parser_charset(default_charset_info)) { |
| 5323 | 12093 | global_system_variables.collation_connection = default_charset_info; | |
| 5324 | 12093 | global_system_variables.character_set_results = default_charset_info; | |
| 5325 | 12093 | global_system_variables.character_set_client = default_charset_info; | |
| 5326 | } else { | ||
| 5327 |
7/14✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 14 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 14 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 14 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 14 times.
✗ Branch 13 not taken.
|
14 | LogErr(INFORMATION_LEVEL, ER_FIXING_CLIENT_CHARSET, |
| 5328 | default_charset_info->csname, my_charset_latin1.csname); | ||
| 5329 | 14 | global_system_variables.collation_connection = &my_charset_latin1; | |
| 5330 | 14 | global_system_variables.character_set_results = &my_charset_latin1; | |
| 5331 | 14 | global_system_variables.character_set_client = &my_charset_latin1; | |
| 5332 | } | ||
| 5333 | |||
| 5334 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12107 times.
|
12107 | if (!(character_set_filesystem = get_charset_by_csname( |
| 5335 | character_set_filesystem_name, MY_CS_PRIMARY, MYF(MY_WME)))) | ||
| 5336 | ✗ | return 1; | |
| 5337 | else | ||
| 5338 | 12107 | warn_on_deprecated_charset(nullptr, character_set_filesystem, | |
| 5339 | character_set_filesystem_name, | ||
| 5340 | "--character-set-filesystem"); | ||
| 5341 | 12107 | global_system_variables.character_set_filesystem = character_set_filesystem; | |
| 5342 | |||
| 5343 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12107 times.
|
12107 | if (lex_init()) { |
| 5344 | ✗ | LogErr(ERROR_LEVEL, ER_OOM); | |
| 5345 | ✗ | return 1; | |
| 5346 | } | ||
| 5347 | |||
| 5348 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12107 times.
|
12109 | while (!(my_default_lc_time_names = my_locale_by_name( |
| 5349 | nullptr, lc_time_names_name, strlen(lc_time_names_name)))) { | ||
| 5350 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | LogErr(ERROR_LEVEL, ER_FAILED_TO_FIND_LOCALE_NAME, lc_time_names_name); |
| 5351 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | if (!my_strcasecmp(&my_charset_latin1, lc_time_names_name, |
| 5352 | mysqld_default_locale_name)) | ||
| 5353 | ✗ | return 1; | |
| 5354 | 2 | lc_time_names_name = mysqld_default_locale_name; | |
| 5355 | } | ||
| 5356 | 12107 | global_system_variables.lc_time_names = my_default_lc_time_names; | |
| 5357 | |||
| 5358 | /* check log options and issue warnings if needed */ | ||
| 5359 |
3/4✓ Branch 0 taken 11534 times.
✓ Branch 1 taken 573 times.
✓ Branch 2 taken 11534 times.
✗ Branch 3 not taken.
|
12107 | if (opt_general_log && opt_general_logname && |
| 5360 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11534 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11534 | !(log_output_options & LOG_FILE) && !(log_output_options & LOG_NONE)) |
| 5361 | ✗ | LogErr(WARNING_LEVEL, ER_LOG_FILES_GIVEN_LOG_OUTPUT_IS_TABLE, | |
| 5362 | "--general-log-file option"); | ||
| 5363 | |||
| 5364 |
4/6✓ Branch 0 taken 11534 times.
✓ Branch 1 taken 573 times.
✓ Branch 2 taken 11534 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11534 times.
|
12107 | if (opt_slow_log && opt_slow_logname && !(log_output_options & LOG_FILE) && |
| 5365 | ✗ | !(log_output_options & LOG_NONE)) | |
| 5366 | ✗ | LogErr(WARNING_LEVEL, ER_LOG_FILES_GIVEN_LOG_OUTPUT_IS_TABLE, | |
| 5367 | "--slow-query-log-file option"); | ||
| 5368 | |||
| 5369 |
3/4✓ Branch 0 taken 11538 times.
✓ Branch 1 taken 569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12107 times.
|
23645 | if (opt_general_logname && |
| 5370 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11538 times.
|
11538 | !is_valid_log_name(opt_general_logname, strlen(opt_general_logname))) { |
| 5371 | ✗ | LogErr(ERROR_LEVEL, ER_LOG_FILE_INVALID, "--general_log_file", | |
| 5372 | opt_general_logname); | ||
| 5373 | ✗ | return 1; | |
| 5374 | } | ||
| 5375 | |||
| 5376 |
3/4✓ Branch 0 taken 11538 times.
✓ Branch 1 taken 569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12107 times.
|
23645 | if (opt_slow_logname && |
| 5377 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11538 times.
|
11538 | !is_valid_log_name(opt_slow_logname, strlen(opt_slow_logname))) { |
| 5378 | ✗ | LogErr(ERROR_LEVEL, ER_LOG_FILE_INVALID, "--slow_query_log_file", | |
| 5379 | opt_slow_logname); | ||
| 5380 | ✗ | return 1; | |
| 5381 | } | ||
| 5382 | |||
| 5383 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12103 times.
|
12107 | if (global_system_variables.transaction_write_set_extraction == |
| 5384 | 4 | HASH_ALGORITHM_OFF && | |
| 5385 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
|
4 | mysql_bin_log.m_dependency_tracker.m_opt_tracking_mode != |
| 5386 | DEPENDENCY_TRACKING_COMMIT_ORDER) { | ||
| 5387 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | LogErr(ERROR_LEVEL, |
| 5388 | ER_TX_EXTRACTION_ALGORITHM_FOR_BINLOG_TX_DEPEDENCY_TRACKING, | ||
| 5389 | "XXHASH64 or MURMUR32", "WRITESET or WRITESET_SESSION"); | ||
| 5390 | 2 | return 1; | |
| 5391 | } else | ||
| 5392 | 12105 | mysql_bin_log.m_dependency_tracker.tracking_mode_changed(); | |
| 5393 | |||
| 5394 | #define FIX_LOG_VAR(VAR, ALT) \ | ||
| 5395 | if (!VAR || !*VAR) VAR = ALT; | ||
| 5396 | |||
| 5397 |
3/4✓ Branch 0 taken 11536 times.
✓ Branch 1 taken 569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11536 times.
|
12105 | FIX_LOG_VAR(opt_general_logname, |
| 5398 | make_query_log_name(logname_path, QUERY_LOG_GENERAL)); | ||
| 5399 |
3/4✓ Branch 0 taken 11536 times.
✓ Branch 1 taken 569 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11536 times.
|
12105 | FIX_LOG_VAR(opt_slow_logname, |
| 5400 | my_strdup(key_memory_LOG_name, | ||
| 5401 | make_query_log_name(slow_logname_path, QUERY_LOG_SLOW), | ||
| 5402 | MYF(MY_WME))); | ||
| 5403 | |||
| 5404 | #if defined(ENABLED_DEBUG_SYNC) | ||
| 5405 | /* Initialize the debug sync facility. See debug_sync.cc. */ | ||
| 5406 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12105 times.
|
12105 | if (debug_sync_init()) return 1; /* purecov: tested */ |
| 5407 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 5408 | |||
| 5409 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12100 times.
|
12105 | if (opt_validate_config) return 0; |
| 5410 | |||
| 5411 | /* create the data directory if requested */ | ||
| 5412 |
4/4✓ Branch 0 taken 301 times.
✓ Branch 1 taken 11799 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12097 times.
|
12401 | if (unlikely(opt_initialize) && |
| 5413 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 298 times.
|
301 | initialize_create_data_directory(mysql_real_data_home)) |
| 5414 | 3 | return 1; | |
| 5415 | |||
| 5416 | /* | ||
| 5417 | Ensure that lower_case_table_names is set on system where we have case | ||
| 5418 | insensitive names. If this is not done the users MyISAM tables will | ||
| 5419 | get corrupted if accesses with names of different case. | ||
| 5420 | */ | ||
| 5421 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12097 times.
|
12097 | DBUG_PRINT("info", ("lower_case_table_names: %d", lower_case_table_names)); |
| 5422 | 12097 | lower_case_file_system = | |
| 5423 | 12097 | (test_if_case_insensitive(mysql_real_data_home) == 1); | |
| 5424 |
3/4✓ Branch 0 taken 11863 times.
✓ Branch 1 taken 234 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11863 times.
|
12097 | if (!lower_case_table_names && lower_case_file_system) { |
| 5425 | ✗ | if (lower_case_table_names_used) { | |
| 5426 | ✗ | LogErr(ERROR_LEVEL, ER_LOWER_CASE_TABLE_NAMES_CS_DD_ON_CI_FS_UNSUPPORTED); | |
| 5427 | ✗ | return 1; | |
| 5428 | } else { | ||
| 5429 | ✗ | LogErr(WARNING_LEVEL, ER_LOWER_CASE_TABLE_NAMES_USING_2, | |
| 5430 | mysql_real_data_home); | ||
| 5431 | ✗ | lower_case_table_names = 2; | |
| 5432 | } | ||
| 5433 |
3/4✓ Branch 0 taken 16 times.
✓ Branch 1 taken 12081 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
|
12097 | } else if (lower_case_table_names == 2 && !lower_case_file_system) { |
| 5434 |
7/14✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
|
16 | LogErr(WARNING_LEVEL, ER_LOWER_CASE_TABLE_NAMES_USING_0, |
| 5435 | mysql_real_data_home); | ||
| 5436 | 16 | lower_case_table_names = 0; | |
| 5437 | } | ||
| 5438 | |||
| 5439 | /* Reset table_alias_charset, now that lower_case_table_names is set. */ | ||
| 5440 | 12097 | table_alias_charset = | |
| 5441 |
2/2✓ Branch 0 taken 218 times.
✓ Branch 1 taken 11879 times.
|
12097 | (lower_case_table_names ? &my_charset_utf8_tolower_ci : &my_charset_bin); |
| 5442 | |||
| 5443 | /* | ||
| 5444 | Build do_table and ignore_table rules to hashes | ||
| 5445 | after the resetting of table_alias_charset. | ||
| 5446 | */ | ||
| 5447 |
2/4✓ Branch 0 taken 12097 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12097 times.
|
24194 | if (rpl_global_filter.build_do_table_hash() || |
| 5448 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12097 times.
|
12097 | rpl_global_filter.build_ignore_table_hash()) { |
| 5449 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_HASH_DO_AND_IGNORE_RULES); | |
| 5450 | ✗ | return 1; | |
| 5451 | } | ||
| 5452 | |||
| 5453 | /* | ||
| 5454 | Reset the P_S view for global replication filter at | ||
| 5455 | the end of server startup. | ||
| 5456 | */ | ||
| 5457 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 5458 | 12097 | rpl_global_filter.wrlock(); | |
| 5459 | 12097 | rpl_global_filter.reset_pfs_view(); | |
| 5460 | 12097 | rpl_global_filter.unlock(); | |
| 5461 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 5462 | |||
| 5463 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12097 times.
|
12097 | if (rpl_channel_filters.build_do_and_ignore_table_hashes()) return 1; |
| 5464 | |||
| 5465 | 12097 | return 0; | |
| 5466 | } | ||
| 5467 | |||
| 5468 | 12142 | static int init_thread_environment() { | |
| 5469 | 12142 | mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); | |
| 5470 | 12142 | mysql_mutex_init(key_LOCK_manager, &LOCK_manager, MY_MUTEX_INIT_FAST); | |
| 5471 | 12142 | mysql_mutex_init(key_LOCK_crypt, &LOCK_crypt, MY_MUTEX_INIT_FAST); | |
| 5472 | 12142 | mysql_mutex_init(key_LOCK_user_conn, &LOCK_user_conn, MY_MUTEX_INIT_FAST); | |
| 5473 | 12142 | mysql_mutex_init(key_LOCK_global_system_variables, | |
| 5474 | &LOCK_global_system_variables, MY_MUTEX_INIT_FAST); | ||
| 5475 | 12142 | mysql_rwlock_init(key_rwlock_LOCK_system_variables_hash, | |
| 5476 | &LOCK_system_variables_hash); | ||
| 5477 | 12142 | mysql_mutex_init(key_LOCK_prepared_stmt_count, &LOCK_prepared_stmt_count, | |
| 5478 | MY_MUTEX_INIT_FAST); | ||
| 5479 | 12142 | mysql_mutex_init(key_LOCK_replica_list, &LOCK_replica_list, | |
| 5480 | MY_MUTEX_INIT_FAST); | ||
| 5481 | 12142 | mysql_mutex_init(key_LOCK_sql_replica_skip_counter, | |
| 5482 | &LOCK_sql_replica_skip_counter, MY_MUTEX_INIT_FAST); | ||
| 5483 | 12142 | mysql_mutex_init(key_LOCK_replica_net_timeout, &LOCK_replica_net_timeout, | |
| 5484 | MY_MUTEX_INIT_FAST); | ||
| 5485 | 12142 | mysql_mutex_init(key_LOCK_replica_trans_dep_tracker, | |
| 5486 | &LOCK_replica_trans_dep_tracker, MY_MUTEX_INIT_FAST); | ||
| 5487 | 12142 | mysql_mutex_init(key_LOCK_error_messages, &LOCK_error_messages, | |
| 5488 | MY_MUTEX_INIT_FAST); | ||
| 5489 | 12142 | mysql_mutex_init(key_LOCK_uuid_generator, &LOCK_uuid_generator, | |
| 5490 | MY_MUTEX_INIT_FAST); | ||
| 5491 | 12142 | mysql_mutex_init(key_LOCK_sql_rand, &LOCK_sql_rand, MY_MUTEX_INIT_FAST); | |
| 5492 | 12142 | mysql_mutex_init(key_LOCK_log_throttle_qni, &LOCK_log_throttle_qni, | |
| 5493 | MY_MUTEX_INIT_FAST); | ||
| 5494 | 12142 | mysql_mutex_init(key_LOCK_default_password_lifetime, | |
| 5495 | &LOCK_default_password_lifetime, MY_MUTEX_INIT_FAST); | ||
| 5496 | 12142 | mysql_mutex_init(key_LOCK_mandatory_roles, &LOCK_mandatory_roles, | |
| 5497 | MY_MUTEX_INIT_FAST); | ||
| 5498 | 12142 | mysql_mutex_init(key_LOCK_password_history, &LOCK_password_history, | |
| 5499 | MY_MUTEX_INIT_FAST); | ||
| 5500 | 12142 | mysql_mutex_init(key_LOCK_password_reuse_interval, | |
| 5501 | &LOCK_password_reuse_interval, MY_MUTEX_INIT_FAST); | ||
| 5502 | 12142 | mysql_rwlock_init(key_rwlock_LOCK_sys_init_connect, &LOCK_sys_init_connect); | |
| 5503 | 12142 | mysql_rwlock_init(key_rwlock_LOCK_sys_init_replica, &LOCK_sys_init_replica); | |
| 5504 | 12142 | mysql_cond_init(key_COND_manager, &COND_manager); | |
| 5505 | 12142 | mysql_mutex_init(key_LOCK_server_started, &LOCK_server_started, | |
| 5506 | MY_MUTEX_INIT_FAST); | ||
| 5507 | 12142 | mysql_cond_init(key_COND_server_started, &COND_server_started); | |
| 5508 | 12142 | mysql_mutex_init(key_LOCK_reset_gtid_table, &LOCK_reset_gtid_table, | |
| 5509 | MY_MUTEX_INIT_FAST); | ||
| 5510 | 12142 | mysql_mutex_init(key_LOCK_compress_gtid_table, &LOCK_compress_gtid_table, | |
| 5511 | MY_MUTEX_INIT_FAST); | ||
| 5512 | 12142 | mysql_mutex_init(key_LOCK_collect_instance_log, &LOCK_collect_instance_log, | |
| 5513 | MY_MUTEX_INIT_FAST); | ||
| 5514 | 12142 | mysql_cond_init(key_COND_compress_gtid_table, &COND_compress_gtid_table); | |
| 5515 | |||
| 5516 | 12142 | mysql_mutex_init(key_LOCK_global_user_client_stats, | |
| 5517 | &LOCK_global_user_client_stats, MY_MUTEX_INIT_FAST); | ||
| 5518 | 12142 | mysql_mutex_init(key_LOCK_global_table_stats, &LOCK_global_table_stats, | |
| 5519 | MY_MUTEX_INIT_FAST); | ||
| 5520 | 12142 | mysql_mutex_init(key_LOCK_global_index_stats, &LOCK_global_index_stats, | |
| 5521 | MY_MUTEX_INIT_FAST); | ||
| 5522 | |||
| 5523 | 12142 | Events::init_mutexes(); | |
| 5524 | #if defined(_WIN32) | ||
| 5525 | mysql_mutex_init(key_LOCK_handler_count, &LOCK_handler_count, | ||
| 5526 | MY_MUTEX_INIT_FAST); | ||
| 5527 | mysql_cond_init(key_COND_handler_count, &COND_handler_count); | ||
| 5528 | mysql_rwlock_init(key_rwlock_LOCK_named_pipe_full_access_group, | ||
| 5529 | &LOCK_named_pipe_full_access_group); | ||
| 5530 | #else | ||
| 5531 | 12142 | mysql_mutex_init(key_LOCK_socket_listener_active, | |
| 5532 | &LOCK_socket_listener_active, MY_MUTEX_INIT_FAST); | ||
| 5533 | 12142 | mysql_cond_init(key_COND_socket_listener_active, | |
| 5534 | &COND_socket_listener_active); | ||
| 5535 | 12142 | mysql_mutex_init(key_LOCK_start_signal_handler, &LOCK_start_signal_handler, | |
| 5536 | MY_MUTEX_INIT_FAST); | ||
| 5537 | 12142 | mysql_cond_init(key_COND_start_signal_handler, &COND_start_signal_handler); | |
| 5538 | #endif // _WIN32 | ||
| 5539 | /* Parameter for threads created for connections */ | ||
| 5540 | 12142 | (void)my_thread_attr_init(&connection_attrib); | |
| 5541 | 12142 | my_thread_attr_setdetachstate(&connection_attrib, MY_THREAD_CREATE_DETACHED); | |
| 5542 | #ifndef _WIN32 | ||
| 5543 | 12142 | pthread_attr_setscope(&connection_attrib, PTHREAD_SCOPE_SYSTEM); | |
| 5544 | #endif | ||
| 5545 | |||
| 5546 | 12142 | mysql_mutex_init(key_LOCK_keyring_operations, &LOCK_keyring_operations, | |
| 5547 | MY_MUTEX_INIT_FAST); | ||
| 5548 | 12142 | mysql_mutex_init(key_LOCK_tls_ctx_options, &LOCK_tls_ctx_options, | |
| 5549 | MY_MUTEX_INIT_FAST); | ||
| 5550 | 12142 | mysql_mutex_init(key_LOCK_rotate_binlog_master_key, | |
| 5551 | &LOCK_rotate_binlog_master_key, MY_MUTEX_INIT_FAST); | ||
| 5552 | 12142 | mysql_mutex_init(key_LOCK_admin_tls_ctx_options, &LOCK_admin_tls_ctx_options, | |
| 5553 | MY_MUTEX_INIT_FAST); | ||
| 5554 | 12142 | mysql_mutex_init(key_LOCK_partial_revokes, &LOCK_partial_revokes, | |
| 5555 | MY_MUTEX_INIT_FAST); | ||
| 5556 | 12142 | mysql_mutex_init(key_LOCK_authentication_policy, &LOCK_authentication_policy, | |
| 5557 | MY_MUTEX_INIT_FAST); | ||
| 5558 | 12142 | mysql_mutex_init(key_LOCK_global_conn_mem_limit, &LOCK_global_conn_mem_limit, | |
| 5559 | MY_MUTEX_INIT_FAST); | ||
| 5560 | 12142 | return 0; | |
| 5561 | } | ||
| 5562 | |||
| 5563 | static PSI_memory_key key_memory_openssl = PSI_NOT_INSTRUMENTED; | ||
| 5564 | |||
| 5565 | #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 5566 | #define FILE_LINE_ARGS | ||
| 5567 | #else | ||
| 5568 | #define FILE_LINE_ARGS , const char *, int | ||
| 5569 | #endif | ||
| 5570 | |||
| 5571 | 140924066 | static void *my_openssl_malloc(size_t size FILE_LINE_ARGS) { | |
| 5572 | 140924066 | return my_malloc(key_memory_openssl, size, MYF(MY_WME)); | |
| 5573 | } | ||
| 5574 | 5052889 | static void *my_openssl_realloc(void *ptr, size_t size FILE_LINE_ARGS) { | |
| 5575 | 5052889 | return my_realloc(key_memory_openssl, ptr, size, MYF(MY_WME)); | |
| 5576 | } | ||
| 5577 | 182860362 | static void my_openssl_free(void *ptr FILE_LINE_ARGS) { return my_free(ptr); } | |
| 5578 | |||
| 5579 | 12109 | static void init_ssl() { | |
| 5580 | #if defined(HAVE_PSI_MEMORY_INTERFACE) | ||
| 5581 | static PSI_memory_info all_openssl_memory[] = { | ||
| 5582 | {&key_memory_openssl, "openssl_malloc", 0, 0, | ||
| 5583 | "All memory used by openSSL"}}; | ||
| 5584 | 12109 | mysql_memory_register("mysqld_openssl", all_openssl_memory, | |
| 5585 | (int)array_elements(all_openssl_memory)); | ||
| 5586 | #endif /* defined(HAVE_PSI_MEMORY_INTERFACE) */ | ||
| 5587 | 12109 | int ret = CRYPTO_set_mem_functions(my_openssl_malloc, my_openssl_realloc, | |
| 5588 | my_openssl_free); | ||
| 5589 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | if (ret == 0) |
| 5590 | ✗ | LogErr(WARNING_LEVEL, ER_SSL_MEMORY_INSTRUMENTATION_INIT_FAILED, | |
| 5591 | "CRYPTO_set_mem_functions"); | ||
| 5592 | 12109 | ssl_start(); | |
| 5593 | 12109 | } | |
| 5594 | |||
| 5595 | 11768 | static int init_ssl_communication() { | |
| 5596 | 11768 | char ssl_err_string[OPENSSL_ERROR_LENGTH] = {'\0'}; | |
| 5597 |
3/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11767 times.
|
11768 | if (set_fips_mode(opt_ssl_fips_mode, ssl_err_string)) { |
| 5598 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(ERROR_LEVEL, ER_SSL_FIPS_MODE_ERROR, ssl_err_string); |
| 5599 | 1 | return 1; | |
| 5600 | } | ||
| 5601 |
4/6✓ Branch 0 taken 11767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11767 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 11761 times.
|
11767 | if (TLS_channel::singleton_init(&mysql_main, mysql_main_channel, opt_use_ssl, |
| 5602 | &server_main_callback, opt_initialize)) | ||
| 5603 | 6 | return 1; | |
| 5604 | |||
| 5605 | /* | ||
| 5606 | The default value of --admin-ssl is ON. If it is set | ||
| 5607 | to off, we should treat it as an explicit attempt to | ||
| 5608 | set TLS off for admin channel and thereby not use | ||
| 5609 | main channel's TLS configuration. | ||
| 5610 | */ | ||
| 5611 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11758 times.
|
11761 | if (!opt_use_admin_ssl) g_admin_ssl_configured = true; |
| 5612 | |||
| 5613 | 11761 | bool initialize_admin_tls = | |
| 5614 |
2/2✓ Branch 0 taken 34 times.
✓ Branch 1 taken 11437 times.
|
11471 | (!opt_initialize && (my_admin_bind_addr_str != nullptr)) |
| 5615 |
2/2✓ Branch 0 taken 11471 times.
✓ Branch 1 taken 290 times.
|
23232 | ? opt_use_admin_ssl |
| 5616 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 2 times.
|
34 | : false; |
| 5617 | |||
| 5618 | 11761 | Ssl_init_callback_server_admin server_admin_callback; | |
| 5619 |
3/6✓ Branch 0 taken 11761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11761 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11761 times.
|
11761 | if (TLS_channel::singleton_init(&mysql_admin, mysql_admin_channel, |
| 5620 | initialize_admin_tls, &server_admin_callback, | ||
| 5621 | opt_initialize)) | ||
| 5622 | ✗ | return 1; | |
| 5623 | |||
| 5624 |
6/6✓ Branch 0 taken 32 times.
✓ Branch 1 taken 11729 times.
✓ Branch 2 taken 20 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 20 times.
✓ Branch 5 taken 11741 times.
|
11761 | if (initialize_admin_tls && !g_admin_ssl_configured) { |
| 5625 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | Lock_and_access_ssl_acceptor_context context(mysql_main); |
| 5626 |
3/4✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✓ Branch 3 taken 1 times.
|
20 | if (context.have_ssl()) |
| 5627 |
8/16✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 19 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 19 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 19 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 19 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 19 times.
✗ Branch 15 not taken.
|
19 | LogErr(SYSTEM_LEVEL, ER_TLS_CONFIGURATION_REUSED, |
| 5628 | mysql_admin_channel.c_str(), mysql_main_channel.c_str()); | ||
| 5629 | 20 | } | |
| 5630 | |||
| 5631 | #if OPENSSL_VERSION_NUMBER < 0x10100000L | ||
| 5632 | ERR_remove_thread_state(0); | ||
| 5633 | #endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */ | ||
| 5634 | |||
| 5635 |
3/4✓ Branch 0 taken 11761 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 11758 times.
|
11761 | if (init_rsa_keys()) return 1; |
| 5636 | 11758 | return 0; | |
| 5637 | 11761 | } | |
| 5638 | |||
| 5639 | 10491 | static void end_ssl() { | |
| 5640 | 10491 | TLS_channel::singleton_deinit(mysql_main); | |
| 5641 | 10491 | TLS_channel::singleton_deinit(mysql_admin); | |
| 5642 | 10491 | deinit_rsa_keys(); | |
| 5643 | 10491 | } | |
| 5644 | |||
| 5645 | /** | ||
| 5646 | Generate a UUID and save it into server_uuid variable. | ||
| 5647 | |||
| 5648 | @return Return 0 or 1 if an error occurred. | ||
| 5649 | */ | ||
| 5650 | 5311 | static int generate_server_uuid() { | |
| 5651 | THD *thd; | ||
| 5652 | Item_func_uuid *func_uuid; | ||
| 5653 | 5311 | String uuid; | |
| 5654 | |||
| 5655 | /* | ||
| 5656 | To be able to run this from boot, we allocate a temporary THD, | ||
| 5657 | since plugins are not yet loaded we pass false to temporary THD. | ||
| 5658 | */ | ||
| 5659 |
3/6✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5311 times.
|
5311 | if (!(thd = new THD(false))) { |
| 5660 | ✗ | LogErr(ERROR_LEVEL, ER_NO_THD_NO_UUID); | |
| 5661 | ✗ | return 1; | |
| 5662 | } | ||
| 5663 | 5311 | thd->thread_stack = (char *)&thd; | |
| 5664 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | thd->store_globals(); |
| 5665 | |||
| 5666 | /* | ||
| 5667 | Initialize the variables which are used during "uuid generator | ||
| 5668 | initialization" with values that should normally differ between | ||
| 5669 | mysqlds on the same host. This avoids that another mysqld started | ||
| 5670 | at the same time on the same host get the same "server_uuid". | ||
| 5671 | */ | ||
| 5672 | |||
| 5673 | 5311 | const time_t save_server_start_time = server_start_time; | |
| 5674 | 5311 | server_start_time += ((ulonglong)current_pid << 48) + current_pid; | |
| 5675 | 5311 | thd->status_var.bytes_sent = (ulonglong)thd; | |
| 5676 | |||
| 5677 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | lex_start(thd); |
| 5678 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
10622 | func_uuid = new (thd->mem_root) Item_func_uuid(); |
| 5679 | 5311 | func_uuid->fixed = true; | |
| 5680 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | func_uuid->val_str(&uuid); |
| 5681 | |||
| 5682 | // Restore global variables used for salting | ||
| 5683 | 5311 | server_start_time = save_server_start_time; | |
| 5684 | |||
| 5685 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | delete thd; |
| 5686 | |||
| 5687 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | strncpy(server_uuid, uuid.c_ptr(), sizeof(server_uuid)); |
| 5688 |
3/4✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 5308 times.
|
5311 | DBUG_EXECUTE_IF("server_uuid_deterministic", |
| 5689 | memcpy(server_uuid, "00000000-1111-0000-1111-000000000000", | ||
| 5690 | UUID_LENGTH);); | ||
| 5691 | 5311 | server_uuid[UUID_LENGTH] = '\0'; | |
| 5692 | 5311 | return 0; | |
| 5693 | 5311 | } | |
| 5694 | |||
| 5695 | /** | ||
| 5696 | Save all options which was auto-generated by server-self into the given file. | ||
| 5697 | |||
| 5698 | @param fname The name of the file in which the auto-generated options will b | ||
| 5699 | e saved. | ||
| 5700 | |||
| 5701 | @return Return 0 or 1 if an error occurred. | ||
| 5702 | */ | ||
| 5703 | 5311 | static int flush_auto_options(const char *fname) { | |
| 5704 | File fd; | ||
| 5705 | 5311 | IO_CACHE io_cache; | |
| 5706 | 5311 | int result = 0; | |
| 5707 | |||
| 5708 |
2/4✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5311 times.
|
5311 | if ((fd = my_open(fname, O_CREAT | O_RDWR, MYF(MY_WME))) < 0) { |
| 5709 | ✗ | LogErr(ERROR_LEVEL, ER_AUTO_OPTIONS_FAILED, "file", fname, my_errno()); | |
| 5710 | ✗ | return 1; | |
| 5711 | } | ||
| 5712 | |||
| 5713 |
2/4✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5311 times.
|
5311 | if (init_io_cache(&io_cache, fd, IO_SIZE * 2, WRITE_CACHE, 0L, false, |
| 5714 | MYF(MY_WME))) { | ||
| 5715 | ✗ | LogErr(ERROR_LEVEL, ER_AUTO_OPTIONS_FAILED, "a cache on ", fname, | |
| 5716 | my_errno()); | ||
| 5717 | ✗ | my_close(fd, MYF(MY_WME)); | |
| 5718 | ✗ | return 1; | |
| 5719 | } | ||
| 5720 | |||
| 5721 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | my_b_seek(&io_cache, 0L); |
| 5722 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | my_b_printf(&io_cache, "%s\n", "[auto]"); |
| 5723 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | my_b_printf(&io_cache, "server-uuid=%s\n", server_uuid); |
| 5724 | |||
| 5725 |
5/10✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5311 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 5311 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 5311 times.
|
5311 | if (flush_io_cache(&io_cache) || my_sync(fd, MYF(MY_WME))) result = 1; |
| 5726 | |||
| 5727 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | my_close(fd, MYF(MY_WME)); |
| 5728 |
1/2✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
|
5311 | end_io_cache(&io_cache); |
| 5729 | 5311 | return result; | |
| 5730 | } | ||
| 5731 | |||
| 5732 | /** | ||
| 5733 | File 'auto.cnf' resides in the data directory to hold values of options that | ||
| 5734 | server evaluates itself and that needs to be durable to sustain the server | ||
| 5735 | restart. There is only a section ['auto'] in the file. All these options are | ||
| 5736 | in the section. Only one option exists now, it is server_uuid. | ||
| 5737 | Note, the user may not supply any literal value to these auto-options, and | ||
| 5738 | only allowed to trigger (re)evaluation. | ||
| 5739 | For instance, 'server_uuid' value will be evaluated and stored if there is | ||
| 5740 | no corresponding line in the file. | ||
| 5741 | Because of the specifics of the auto-options, they need separate storage. | ||
| 5742 | Meanwhile, it is the 'auto.cnf' that has the same structure as 'my.cnf'. | ||
| 5743 | |||
| 5744 | @todo consider to implement sql-query-able persistent storage by WL#5279. | ||
| 5745 | @return Return 0 or 1 if an error occurred. | ||
| 5746 | */ | ||
| 5747 | 12036 | static int init_server_auto_options() { | |
| 5748 | 12036 | bool flush = false; | |
| 5749 | char fname[FN_REFLEN]; | ||
| 5750 | 12036 | char name[] = "auto"; | |
| 5751 | 12036 | char *name_ptr = name; | |
| 5752 | 12036 | const char *groups[] = {"auto", nullptr}; | |
| 5753 | 12036 | char *uuid = nullptr; | |
| 5754 | 12036 | my_option auto_options[] = { | |
| 5755 | {"server-uuid", 0, "", &uuid, &uuid, nullptr, GET_STR, REQUIRED_ARG, 0, 0, | ||
| 5756 | 0, nullptr, 0, nullptr}, | ||
| 5757 | {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, | ||
| 5758 | 12036 | 0, nullptr, 0, nullptr}}; | |
| 5759 | |||
| 5760 |
1/2✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
|
12036 | DBUG_TRACE; |
| 5761 | |||
| 5762 |
2/4✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12036 times.
|
12036 | if (nullptr == fn_format(fname, "auto.cnf", mysql_real_data_home_ptr, "", |
| 5763 | MY_UNPACK_FILENAME | MY_SAFE_PATH)) | ||
| 5764 | ✗ | return 1; | |
| 5765 | |||
| 5766 | /* load_defaults require argv[0] is not null */ | ||
| 5767 | 12036 | char **argv = &name_ptr; | |
| 5768 | 12036 | int argc = 1; | |
| 5769 |
3/4✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12035 times.
|
12036 | if (!check_file_permissions(fname, false)) { |
| 5770 | /* | ||
| 5771 | Found a world writable file hence removing it as it is dangerous to write | ||
| 5772 | a new UUID into the same file. | ||
| 5773 | */ | ||
| 5774 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | my_delete(fname, MYF(MY_WME)); |
| 5775 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(WARNING_LEVEL, ER_WRITABLE_CONFIG_REMOVED, fname); |
| 5776 | } | ||
| 5777 | |||
| 5778 | /* load all options in 'auto.cnf'. */ | ||
| 5779 | 12036 | MEM_ROOT alloc{PSI_NOT_INSTRUMENTED, 512}; | |
| 5780 |
2/4✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12036 times.
|
12036 | if (my_load_defaults(fname, groups, &argc, &argv, &alloc, nullptr)) return 1; |
| 5781 | |||
| 5782 |
2/4✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12036 times.
|
12036 | if (handle_options(&argc, &argv, auto_options, mysqld_get_one_option)) |
| 5783 | ✗ | return 1; | |
| 5784 | |||
| 5785 |
3/8✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12036 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12036 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
12036 | DBUG_PRINT("info", ("uuid=%p=%s server_uuid=%s", uuid, uuid, server_uuid)); |
| 5786 |
2/2✓ Branch 0 taken 6725 times.
✓ Branch 1 taken 5311 times.
|
12036 | if (uuid) { |
| 5787 |
2/4✓ Branch 0 taken 6725 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6725 times.
|
6725 | if (!binary_log::Uuid::is_valid(uuid, binary_log::Uuid::TEXT_LENGTH)) { |
| 5788 | ✗ | LogErr(ERROR_LEVEL, ER_UUID_INVALID); | |
| 5789 | ✗ | goto err; | |
| 5790 | } | ||
| 5791 | /* | ||
| 5792 | Uuid::is_valid() cannot do strict check on the length as it will be | ||
| 5793 | called by GTID::is_valid() as well (GTID = UUID:seq_no). We should | ||
| 5794 | explicitly add the *length check* here in this function. | ||
| 5795 | |||
| 5796 | If UUID length is less than '36' (UUID_LENGTH), that error case would have | ||
| 5797 | got caught in above is_valid check. The below check is to make sure that | ||
| 5798 | length is not greater than UUID_LENGTH i.e., there are no extra characters | ||
| 5799 | (Garbage) at the end of the valid UUID. | ||
| 5800 | */ | ||
| 5801 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6725 times.
|
6725 | if (strlen(uuid) > UUID_LENGTH) { |
| 5802 | ✗ | LogErr(ERROR_LEVEL, ER_UUID_SCRUB, UUID_LENGTH); | |
| 5803 | ✗ | goto err; | |
| 5804 | } | ||
| 5805 | 6725 | strcpy(server_uuid, uuid); | |
| 5806 | } else { | ||
| 5807 |
3/8✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5311 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
5311 | DBUG_PRINT("info", ("generating server_uuid")); |
| 5808 | 5311 | flush = true; | |
| 5809 | /* server_uuid will be set in the function */ | ||
| 5810 |
2/4✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5311 times.
|
5311 | if (generate_server_uuid()) goto err; |
| 5811 |
3/8✓ Branch 0 taken 5311 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 5311 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
5311 | DBUG_PRINT("info", ("generated server_uuid=%s", server_uuid)); |
| 5812 |
3/4✓ Branch 0 taken 5014 times.
✓ Branch 1 taken 297 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5014 times.
|
5311 | if (opt_initialize || opt_initialize_insecure) { |
| 5813 |
8/16✓ Branch 0 taken 297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 297 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 297 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 297 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 297 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 297 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 297 times.
✗ Branch 15 not taken.
|
297 | LogErr(INFORMATION_LEVEL, ER_CREATING_NEW_UUID_FIRST_START, server_uuid); |
| 5814 | |||
| 5815 | } else { | ||
| 5816 |
8/16✓ Branch 0 taken 5014 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5014 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5014 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5014 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5014 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5014 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5014 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5014 times.
✗ Branch 15 not taken.
|
5014 | LogErr(WARNING_LEVEL, ER_CREATING_NEW_UUID, server_uuid); |
| 5817 | } | ||
| 5818 | } | ||
| 5819 | |||
| 5820 |
3/4✓ Branch 0 taken 5311 times.
✓ Branch 1 taken 6725 times.
✓ Branch 2 taken 5311 times.
✗ Branch 3 not taken.
|
12036 | if (flush) return flush_auto_options(fname); |
| 5821 | 6725 | return 0; | |
| 5822 | ✗ | err: | |
| 5823 | ✗ | return 1; | |
| 5824 | 12036 | } | |
| 5825 | |||
| 5826 | 23732 | static bool initialize_storage_engine(const char *se_name, const char *se_kind, | |
| 5827 | plugin_ref *dest_plugin) { | ||
| 5828 | 23732 | LEX_CSTRING name = {se_name, strlen(se_name)}; | |
| 5829 | plugin_ref plugin; | ||
| 5830 | handlerton *hton; | ||
| 5831 |
2/4✓ Branch 0 taken 23732 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23732 times.
✗ Branch 3 not taken.
|
23732 | if ((plugin = ha_resolve_by_name(nullptr, &name, false))) |
| 5832 | 23732 | hton = plugin_data<handlerton *>(plugin); | |
| 5833 | else { | ||
| 5834 | ✗ | LogErr(ERROR_LEVEL, ER_UNKNOWN_UNSUPPORTED_STORAGE_ENGINE, se_name); | |
| 5835 | ✗ | return true; | |
| 5836 | } | ||
| 5837 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23732 times.
|
23732 | if (!ha_storage_engine_is_enabled(hton)) { |
| 5838 | ✗ | if (!opt_initialize) { | |
| 5839 | ✗ | LogErr(ERROR_LEVEL, ER_DEFAULT_SE_UNAVAILABLE, se_kind, se_name); | |
| 5840 | ✗ | return true; | |
| 5841 | } | ||
| 5842 | ✗ | assert(*dest_plugin); | |
| 5843 | } else { | ||
| 5844 | /* | ||
| 5845 | Need to unlock as global_system_variables.table_plugin | ||
| 5846 | was acquired during plugin_register_builtin_and_init_core_se() | ||
| 5847 | */ | ||
| 5848 | 23732 | plugin_ref old_dest_plugin = *dest_plugin; | |
| 5849 | 23732 | *dest_plugin = plugin; | |
| 5850 |
1/2✓ Branch 0 taken 23732 times.
✗ Branch 1 not taken.
|
23732 | plugin_unlock(nullptr, old_dest_plugin); |
| 5851 | } | ||
| 5852 | 23732 | return false; | |
| 5853 | } | ||
| 5854 | |||
| 5855 | 12098 | static void setup_error_log() { | |
| 5856 | /* Setup logs */ | ||
| 5857 | |||
| 5858 | /* | ||
| 5859 | Enable old-fashioned error log, except when the user has requested | ||
| 5860 | help information. Since the implementation of plugin server | ||
| 5861 | variables the help output is now written much later. | ||
| 5862 | |||
| 5863 | log_error_dest can be: | ||
| 5864 | disabled_my_option --log-error was not used or --log-error= | ||
| 5865 | "" --log-error without arguments (no '=') | ||
| 5866 | filename --log-error=filename | ||
| 5867 | */ | ||
| 5868 | |||
| 5869 | #ifdef _WIN32 | ||
| 5870 | /* | ||
| 5871 | Enable the error log file only if console option is not specified | ||
| 5872 | and --help is not used. | ||
| 5873 | */ | ||
| 5874 | bool log_errors_to_file = !is_help_or_validate_option() && !opt_console; | ||
| 5875 | #else | ||
| 5876 | /* | ||
| 5877 | Enable the error log file only if --log-error=filename or --log-error | ||
| 5878 | was used. Logging to file is disabled by default unlike on Windows. | ||
| 5879 | */ | ||
| 5880 | bool log_errors_to_file = | ||
| 5881 |
4/4✓ Branch 0 taken 12079 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 857 times.
✓ Branch 3 taken 11222 times.
|
12098 | !is_help_or_validate_option() && (log_error_dest != disabled_my_option); |
| 5882 | #endif | ||
| 5883 | |||
| 5884 |
2/2✓ Branch 0 taken 857 times.
✓ Branch 1 taken 11241 times.
|
12098 | if (log_errors_to_file) { |
| 5885 | // Construct filename if no filename was given by the user. | ||
| 5886 |
3/4✓ Branch 0 taken 855 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 855 times.
|
857 | if (!log_error_dest[0] || log_error_dest == disabled_my_option) { |
| 5887 | #ifdef _WIN32 | ||
| 5888 | const char *filename = pidfile_name; | ||
| 5889 | #else | ||
| 5890 | 2 | const char *filename = default_logfile_name; | |
| 5891 | #endif | ||
| 5892 | 2 | fn_format(errorlog_filename_buff, filename, mysql_real_data_home, ".err", | |
| 5893 | MY_REPLACE_EXT | /* replace '.<domain>' by '.err', bug#4997 */ | ||
| 5894 | MY_REPLACE_DIR); | ||
| 5895 | 2 | } else | |
| 5896 | 855 | fn_format(errorlog_filename_buff, log_error_dest, mysql_data_home, ".err", | |
| 5897 | MY_UNPACK_FILENAME); | ||
| 5898 | /* | ||
| 5899 | log_error_dest may have been set to disabled_my_option or "" if no | ||
| 5900 | argument was passed, but we need to show the real name in SHOW VARIABLES. | ||
| 5901 | */ | ||
| 5902 | 857 | log_error_dest = errorlog_filename_buff; | |
| 5903 | |||
| 5904 | #ifndef _WIN32 | ||
| 5905 | // Create backup stream to stdout if daemonizing and connected to tty | ||
| 5906 |
4/6✓ Branch 0 taken 2 times.
✓ Branch 1 taken 855 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 857 times.
|
857 | if (opt_daemonize && isatty(STDOUT_FILENO)) { |
| 5907 | ✗ | nstdout = fdopen(dup(STDOUT_FILENO), "a"); | |
| 5908 | ✗ | if (nstdout == nullptr) { | |
| 5909 | ✗ | LogErr(ERROR_LEVEL, ER_DUP_FD_OPEN_FAILED, "stdout", strerror(errno)); | |
| 5910 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 5911 | } | ||
| 5912 | // Display location of error log file on stdout if connected to tty | ||
| 5913 | ✗ | fprintf(nstdout, "mysqld will log errors to %s\n", | |
| 5914 | errorlog_filename_buff); | ||
| 5915 | } | ||
| 5916 | #endif /* ndef _WIN32 */ | ||
| 5917 | |||
| 5918 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 855 times.
|
857 | if (open_error_log(errorlog_filename_buff, false)) |
| 5919 | 2 | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 5920 | |||
| 5921 | #ifdef _WIN32 | ||
| 5922 | // FreeConsole(); // Remove window | ||
| 5923 | #endif /* _WIN32 */ | ||
| 5924 | } else { | ||
| 5925 | // We are logging to stderr and SHOW VARIABLES should reflect that. | ||
| 5926 | 11241 | log_error_dest = "stderr"; | |
| 5927 | } | ||
| 5928 | 12096 | } | |
| 5929 | |||
| 5930 | /** | ||
| 5931 | Try to set the error logging pipeline from @@global.log_error_services. | ||
| 5932 | Try to read the previous run's error log and make it available in | ||
| 5933 | performance_schema.error_log. | ||
| 5934 | Flush the buffered error messages to performance schema and to configured | ||
| 5935 | services, and end error log buffering. | ||
| 5936 | On success, log_error_stage_current becomes | ||
| 5937 | LOG_ERROR_STAGE_COMPONENTS_AND_PFS. | ||
| 5938 | |||
| 5939 | @retval 0 Success | ||
| 5940 | @retval 1 Log pipeline not set up as requested. Caller should abort. | ||
| 5941 | */ | ||
| 5942 | 12056 | static int setup_error_log_components() { | |
| 5943 | 12056 | int ret = 1; // failure unless otherwise specified | |
| 5944 | |||
| 5945 | /* | ||
| 5946 | LOCK_plugin needs to be valid in case we implicitly load | ||
| 5947 | components below that install component-variables. | ||
| 5948 | (Otherwise, an assert will fire as the variable-install | ||
| 5949 | code examines the locks, but plugins have not yet been | ||
| 5950 | initialized.) | ||
| 5951 | */ | ||
| 5952 | 12056 | mysql_mutex_init(0, &LOCK_plugin, MY_MUTEX_INIT_FAST); | |
| 5953 | |||
| 5954 | /* | ||
| 5955 | Now that we have the component infrastructure, check | ||
| 5956 | --log-error-services=... -- is it well-formed, and do | ||
| 5957 | the requested services exist? | ||
| 5958 | As a side-effect, this will load any external logging | ||
| 5959 | components listed. | ||
| 5960 | This way when we run get_options(), any system variables | ||
| 5961 | provided by those logging components will already be | ||
| 5962 | available. | ||
| 5963 | |||
| 5964 | This function loads its components directly without | ||
| 5965 | going through the layer that persists component set-up | ||
| 5966 | in mysql.component. This way, our logging components can | ||
| 5967 | be activated before rather than after InnoDB becomes | ||
| 5968 | available, and InnoDB start-up messages can be logged | ||
| 5969 | using components as a result. | ||
| 5970 | */ | ||
| 5971 |
2/2✓ Branch 0 taken 12054 times.
✓ Branch 1 taken 2 times.
|
12056 | if (log_builtins_error_stack(opt_log_error_services, true, nullptr) == 0) { |
| 5972 | // Syntax is OK and services exist; let's try to initialize them: | ||
| 5973 | size_t pos; | ||
| 5974 | |||
| 5975 |
2/4✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12054 times.
|
12054 | if (log_builtins_error_stack(opt_log_error_services, false, &pos) < 0) { |
| 5976 | ✗ | char *problem = opt_log_error_services; /* purecov: begin inspected */ | |
| 5977 | ✗ | const std::string var_name = "log_error_services"; | |
| 5978 | |||
| 5979 | /* | ||
| 5980 | We failed to set the requested configuration. This can happen | ||
| 5981 | e.g. when a given log-writer does not have sufficient permissions | ||
| 5982 | to open its log files. pos should mark the position in the | ||
| 5983 | configuration string where we ran into trouble. Make a char-pointer | ||
| 5984 | from it so we can inform the user what log-service we could not | ||
| 5985 | initialize. | ||
| 5986 | */ | ||
| 5987 | ✗ | if (pos < strlen(opt_log_error_services)) | |
| 5988 | ✗ | problem = &((char *)opt_log_error_services)[pos]; | |
| 5989 | |||
| 5990 | /* | ||
| 5991 | We could not set the requested pipeline. | ||
| 5992 | Try to fall back to default error logging stack | ||
| 5993 | (by looking up the system variable for this configuration | ||
| 5994 | item and extracting the default value from it). | ||
| 5995 | If that's impossible, print diagnostics, then exit. | ||
| 5996 | */ | ||
| 5997 | ✗ | sys_var *var = find_static_system_variable(var_name); | |
| 5998 | |||
| 5999 | ✗ | if (var != nullptr) { | |
| 6000 | // We found the system variable, now extract the default value: | ||
| 6001 | ✗ | opt_log_error_services = (char *)var->get_default(); | |
| 6002 | ✗ | if (log_builtins_error_stack(opt_log_error_services, false, nullptr) >= | |
| 6003 | 0) { | ||
| 6004 | /* | ||
| 6005 | We managed to set the default pipeline. Now log what was wrong | ||
| 6006 | about the user-supplied value, then shut down. | ||
| 6007 | */ | ||
| 6008 | ✗ | flush_error_log_messages(); | |
| 6009 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_START_ERROR_LOG_SERVICE, var_name.c_str(), | |
| 6010 | problem); | ||
| 6011 | ✗ | goto failure; | |
| 6012 | } | ||
| 6013 | /* | ||
| 6014 | If we arrive here, the user-supplied value was valid, but could | ||
| 6015 | not be set. The default value was found, but also could not be | ||
| 6016 | set. Something is very wrong. Fall-through to below where we | ||
| 6017 | low-level write diagnostics, then abort. | ||
| 6018 | */ | ||
| 6019 | } | ||
| 6020 | |||
| 6021 | /* | ||
| 6022 | We failed to set the default error logging stack (or failed to look | ||
| 6023 | up the default setting). At this point, we don't know whether ANY of | ||
| 6024 | the requested sinks work, so our best bet is to write directly to the | ||
| 6025 | error stream. Then, we abort. | ||
| 6026 | */ | ||
| 6027 | { | ||
| 6028 | char buff[512]; | ||
| 6029 | size_t len; | ||
| 6030 | |||
| 6031 | ✗ | len = snprintf(buff, sizeof(buff), | |
| 6032 | ER_DEFAULT(ER_CANT_START_ERROR_LOG_SERVICE), | ||
| 6033 | var_name.c_str(), problem); | ||
| 6034 | ✗ | len = std::min(len, sizeof(buff) - 1); | |
| 6035 | |||
| 6036 | // Trust nothing. Write directly. Quit. | ||
| 6037 | ✗ | log_write_errstream(buff, len); | |
| 6038 | |||
| 6039 | ✗ | goto failure; | |
| 6040 | } /* purecov: end */ | ||
| 6041 | ✗ | } // value was OK, but could not be set | |
| 6042 | // If we arrive here, the value was OK, and was set successfully. | ||
| 6043 | } else { | ||
| 6044 | /* | ||
| 6045 | We were given an illegal value at start-up, so the default was | ||
| 6046 | used instead. Let's now point our variable back at the default | ||
| 6047 | (i.e. the value actually used) so SELECT @@GLOBAL.log_error_services | ||
| 6048 | will render correct results. | ||
| 6049 | */ | ||
| 6050 | |||
| 6051 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
2 | sys_var *var = find_static_system_variable("log_error_services"); |
| 6052 | 2 | char *default_services = nullptr; | |
| 6053 | |||
| 6054 |
2/4✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
|
4 | if ((var != nullptr) && |
| 6055 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | ((default_services = (char *)var->get_default()) != nullptr)) |
| 6056 | 2 | log_builtins_error_stack(default_services, false, nullptr); | |
| 6057 | |||
| 6058 | // Report that we're falling back to the default value. | ||
| 6059 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | LogErr(WARNING_LEVEL, ER_CANNOT_SET_LOG_ERROR_SERVICES, |
| 6060 | opt_log_error_services); | ||
| 6061 | |||
| 6062 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (default_services != nullptr) opt_log_error_services = default_services; |
| 6063 | } | ||
| 6064 | |||
| 6065 | /* | ||
| 6066 | We'll want to flush whatever log-events we buffered during start-up | ||
| 6067 | to the now available components in a moment. To that end, we now | ||
| 6068 | switch from saving log-events in a buffer to processing them via | ||
| 6069 | the logging-pipeline. | ||
| 6070 | Not switching processors here would result in flushing the buffer | ||
| 6071 | into the buffer. | ||
| 6072 | */ | ||
| 6073 | 12056 | log_line_process_hook_set(log_line_error_stack_run); | |
| 6074 | 12056 | log_error_stage_set(LOG_ERROR_STAGE_COMPONENTS); | |
| 6075 | |||
| 6076 | /* | ||
| 6077 | Set-up the error-log table, performance_schema.error_log. | ||
| 6078 | Try to populate it with previous runs' error-log and events | ||
| 6079 | buffered up to this point. | ||
| 6080 | |||
| 6081 | log_error_read_log_init() initializes the ring-buffer for | ||
| 6082 | performance_schema.error_log. | ||
| 6083 | |||
| 6084 | log_error_read_log() reads an existing error-log (of whatever formatting). | ||
| 6085 | |||
| 6086 | LOG_ERROR_STAGE_COMPONENTS_AND_PFS flags the error logging | ||
| 6087 | stack as fully operational, loadable components and all. | ||
| 6088 | In this mode, all submitted error-log events are also automatically | ||
| 6089 | added to performance_schema.error_log. | ||
| 6090 | |||
| 6091 | flush_error_log_messages() is called once any configured loadable | ||
| 6092 | error log-services are available. It flushes all buffered log-events | ||
| 6093 | to the log-services the user actually wants. | ||
| 6094 | If LOG_ERROR_STAGE_COMPONENTS_AND_PFS is set, also add the | ||
| 6095 | flushed events to performance_schema.error_log. | ||
| 6096 | */ | ||
| 6097 |
2/4✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12056 times.
✗ Branch 3 not taken.
|
12056 | assert((log_error_dest != nullptr) && (log_error_dest[0] != '\0')); |
| 6098 | |||
| 6099 |
2/2✓ Branch 0 taken 11209 times.
✓ Branch 1 taken 847 times.
|
12056 | if (!strcmp(log_error_dest, "stderr")) { |
| 6100 | // If we logging to stderr, there will be no log-file to read. | ||
| 6101 | // As this is a common case in mysql-test-run, we offer a fallback. | ||
| 6102 | |||
| 6103 | // Let the user know we cannot provide info from previous runs. | ||
| 6104 |
7/14✓ Branch 0 taken 11209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11209 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11209 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11209 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11209 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11209 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11209 times.
✗ Branch 13 not taken.
|
11209 | LogErr(INFORMATION_LEVEL, ER_ERROR_LOG_DESTINATION_NOT_A_FILE, "stderr"); |
| 6105 | // init logging to pfs | ||
| 6106 | 11209 | log_error_read_log_init(); | |
| 6107 | // flag log-stack as ready and enable logging to pfs | ||
| 6108 | 11209 | log_error_stage_set(LOG_ERROR_STAGE_COMPONENTS_AND_PFS); | |
| 6109 | // flush messages, sending a copy to pfs | ||
| 6110 | 11209 | flush_error_log_messages(); | |
| 6111 | } else { | ||
| 6112 | // We're logging to a named file. | ||
| 6113 | |||
| 6114 | /* | ||
| 6115 | Flush messages, not sending a copy to pfs -- we'll get the info | ||
| 6116 | from the log-file anyway when we try to restore the previous run's | ||
| 6117 | info. | ||
| 6118 | */ | ||
| 6119 | 847 | flush_error_log_messages(); | |
| 6120 | /* | ||
| 6121 | Try to load error log events from the previous run (if available) | ||
| 6122 | and that from the current start-up into performance_schema.error_log. | ||
| 6123 | */ | ||
| 6124 |
1/2✓ Branch 0 taken 847 times.
✗ Branch 1 not taken.
|
847 | if (!log_error_read_log_init()) log_error_read_log(log_error_dest); |
| 6125 | // flag log-stack as ready and enable logging to pfs | ||
| 6126 | 847 | log_error_stage_set(LOG_ERROR_STAGE_COMPONENTS_AND_PFS); | |
| 6127 | } | ||
| 6128 | |||
| 6129 | 12056 | ret = 0; // Success! | |
| 6130 | |||
| 6131 | 12056 | failure: | |
| 6132 | |||
| 6133 | /* | ||
| 6134 | Destroy lock so plugin_register_early_plugins() > plugin_init_internals() | ||
| 6135 | can properly set up all plugin-related things together below. | ||
| 6136 | */ | ||
| 6137 | 12056 | mysql_mutex_destroy(&LOCK_plugin); | |
| 6138 | |||
| 6139 | 12056 | return ret; | |
| 6140 | } | ||
| 6141 | |||
| 6142 | #if defined(MYSQL_ICU_DATADIR) | ||
| 6143 | |||
| 6144 | // For "bundled" ICU: | ||
| 6145 | // Verify that we can find <directory_path>/icudt69l | ||
| 6146 | // and <directory_path>/icudt69l/unames.icu | ||
| 6147 | // or <directory_path>/icudt69b on Sparc | ||
| 6148 | 11768 | static bool icu_data_directory_is_valid(const char *directory_path) { | |
| 6149 | MY_STAT stat_info; | ||
| 6150 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | bool directory_exists = mysql_file_stat(key_file_misc, directory_path, |
| 6151 | 11768 | &stat_info, MYF(0)) != nullptr; | |
| 6152 |
2/2✓ Branch 0 taken 11757 times.
✓ Branch 1 taken 11 times.
|
11768 | if (directory_exists) { |
| 6153 | char icudt_path[FN_REFLEN]; | ||
| 6154 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | fn_format(icudt_path, ICUDT_DIR, directory_path, "", 0); |
| 6155 | bool icudt_dir_exists = | ||
| 6156 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | mysql_file_stat(key_file_misc, icudt_path, &stat_info, MYF(0)); |
| 6157 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | if (icudt_dir_exists) { |
| 6158 | char icunames_path[FN_REFLEN]; | ||
| 6159 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | fn_format(icunames_path, "unames.icu", icudt_path, "", 0); |
| 6160 | bool icu_unames_exists = | ||
| 6161 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | mysql_file_stat(key_file_misc, icunames_path, &stat_info, MYF(0)); |
| 6162 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | if (icu_unames_exists) { |
| 6163 | 11757 | return true; | |
| 6164 | } | ||
| 6165 | } | ||
| 6166 | } | ||
| 6167 | 11 | return false; | |
| 6168 | } | ||
| 6169 | |||
| 6170 | // For "bundled" ICU: | ||
| 6171 | // Look for icudt69l.lnk in build directory. | ||
| 6172 | 11768 | static char *get_icu_data_directory_in_build_dir(char *to) { | |
| 6173 | char icudt_path[FN_REFLEN]; | ||
| 6174 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | fn_format(icudt_path, ICUDT_DIR, mysql_home, ".lnk", 0); |
| 6175 | MY_STAT stat_info; | ||
| 6176 | bool icudt_lnk_exists = | ||
| 6177 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | mysql_file_stat(key_file_misc, icudt_path, &stat_info, MYF(0)) != nullptr; |
| 6178 |
2/2✓ Branch 0 taken 11757 times.
✓ Branch 1 taken 11 times.
|
11768 | if (icudt_lnk_exists) { |
| 6179 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | File file = mysql_file_open(key_file_misc, icudt_path, O_RDONLY, 0); |
| 6180 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | if (file != -1) { |
| 6181 | char icudt_lnk_contents[FN_REFLEN]; | ||
| 6182 | size_t num_bytes_read = | ||
| 6183 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | mysql_file_read(file, reinterpret_cast<uchar *>(icudt_lnk_contents), |
| 6184 | sizeof(icudt_lnk_contents), 0); | ||
| 6185 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | mysql_file_close(file, 0); |
| 6186 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | if (num_bytes_read != MY_FILE_ERROR) { |
| 6187 | 11757 | icudt_lnk_contents[num_bytes_read] = '\0'; | |
| 6188 | 11757 | memcpy(to, icudt_lnk_contents, num_bytes_read + 1); | |
| 6189 | 11757 | return to; | |
| 6190 | } | ||
| 6191 | } | ||
| 6192 | } | ||
| 6193 | 11 | return nullptr; | |
| 6194 | } | ||
| 6195 | |||
| 6196 | // For "bundled" ICU: | ||
| 6197 | // Look for MYSQL_ICU_DATADIR which depends on INSTALL_PRIV_LIBDIR | ||
| 6198 | 11 | static char *get_icu_data_directory_in_install_dir(char *to) { | |
| 6199 | char buff[FN_REFLEN]; | ||
| 6200 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | const char *mysql_icu_datadir = get_relative_path(MYSQL_ICU_DATADIR); |
| 6201 |
2/4✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11 times.
|
11 | if (test_if_hard_path(mysql_icu_datadir)) |
| 6202 | ✗ | strmake(buff, mysql_icu_datadir, sizeof(buff) - 1); | |
| 6203 | else | ||
| 6204 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | strxnmov(buff, sizeof(buff) - 1, mysql_home, mysql_icu_datadir, NullS); |
| 6205 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | convert_dirname(buff, buff, NullS); |
| 6206 | 11 | memcpy(to, buff, sizeof(buff)); | |
| 6207 | 11 | return to; | |
| 6208 | } | ||
| 6209 | |||
| 6210 | // Where to look for data files for "bundled" ICU: | ||
| 6211 | // Look in environment ICU_DATA. | ||
| 6212 | // In a build sandbox we expect cmake to write a .lnk file. | ||
| 6213 | // In an install directory, we look in MYSQL_ICU_DATADIR. | ||
| 6214 | 11768 | static void init_icu_data_directory() { | |
| 6215 | // Use environment variable if available. | ||
| 6216 | 11768 | const char *env_icu_data = getenv("ICU_DATA"); | |
| 6217 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11768 times.
|
11768 | if (env_icu_data != nullptr) { |
| 6218 | ✗ | if (icu_data_directory_is_valid(env_icu_data)) { | |
| 6219 | 11757 | return; | |
| 6220 | } | ||
| 6221 | ✗ | LogErr(WARNING_LEVEL, ER_REGEXP_MISSING_ICU_DATADIR, env_icu_data); | |
| 6222 | // Continue, looking for ICU in build or install directory. | ||
| 6223 | } | ||
| 6224 | |||
| 6225 | char build_dir_buffer[FN_REFLEN]; | ||
| 6226 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | const char *in_build = get_icu_data_directory_in_build_dir(build_dir_buffer); |
| 6227 |
6/8✓ Branch 0 taken 11757 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 11757 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11757 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11757 times.
✓ Branch 7 taken 11 times.
|
11768 | if (in_build != nullptr && icu_data_directory_is_valid(in_build)) { |
| 6228 |
1/2✓ Branch 0 taken 11757 times.
✗ Branch 1 not taken.
|
11757 | u_setDataDirectory(in_build); |
| 6229 | 11757 | return; | |
| 6230 | } | ||
| 6231 | char install_dir_buffer[FN_REFLEN]; | ||
| 6232 | const char *in_install = | ||
| 6233 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | get_icu_data_directory_in_install_dir(install_dir_buffer); |
| 6234 |
4/8✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 11 times.
|
11 | if (in_install != nullptr && icu_data_directory_is_valid(in_install)) { |
| 6235 | ✗ | u_setDataDirectory(in_install); | |
| 6236 | ✗ | return; | |
| 6237 | } | ||
| 6238 |
8/16✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11 times.
✗ Branch 15 not taken.
|
11 | LogErr(WARNING_LEVEL, ER_REGEXP_MISSING_ICU_DATADIR, install_dir_buffer); |
| 6239 | } | ||
| 6240 | |||
| 6241 | #endif // MYSQL_ICU_DATADIR | ||
| 6242 | |||
| 6243 | 12058 | static int init_server_components() { | |
| 6244 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | buffered_error_log.resize(buffered_error_log_size * 1024); |
| 6245 | |||
| 6246 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | DBUG_TRACE; |
| 6247 | /* | ||
| 6248 | We need to call each of these following functions to ensure that | ||
| 6249 | all things are initialized so that unireg_abort() doesn't fail | ||
| 6250 | */ | ||
| 6251 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | mdl_init(); |
| 6252 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | partitioning_init(); |
| 6253 |
5/10✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12058 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12058 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12058 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 12058 times.
|
12058 | if (table_def_init() || hostname_cache_init(host_cache_size)) |
| 6254 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6255 | |||
| 6256 | /* | ||
| 6257 | This load function has to be called after the opt_plugin_dir variable | ||
| 6258 | is initialized else it will fail to load. | ||
| 6259 | The unload of these components will be done by minimal_chassis_deinit(). | ||
| 6260 | So, no need to call unload of these components. | ||
| 6261 | Since, it is an optional component required for GR, audit log etc. The | ||
| 6262 | error check of the service availability has to be done by those | ||
| 6263 | plugins/components. | ||
| 6264 | */ | ||
| 6265 |
6/6✓ Branch 0 taken 12040 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11743 times.
✓ Branch 3 taken 297 times.
✓ Branch 4 taken 11743 times.
✓ Branch 5 taken 315 times.
|
12058 | if (!is_help_or_validate_option() && !opt_initialize) |
| 6266 |
1/2✓ Branch 0 taken 11743 times.
✗ Branch 1 not taken.
|
11743 | dynamic_loader_srv->load(component_urns, NUMBER_OF_COMPONENTS); |
| 6267 | |||
| 6268 | /* | ||
| 6269 | Timers not needed if only starting with --help. | ||
| 6270 | */ | ||
| 6271 |
2/2✓ Branch 0 taken 12040 times.
✓ Branch 1 taken 18 times.
|
12058 | if (!is_help_or_validate_option()) { |
| 6272 |
2/4✓ Branch 0 taken 12040 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12040 times.
|
12040 | if (my_timer_initialize()) |
| 6273 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_INIT_TIMER, errno); | |
| 6274 | else | ||
| 6275 | 12040 | have_statement_timeout = SHOW_OPTION_YES; | |
| 6276 | } | ||
| 6277 | |||
| 6278 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | randominit(&sql_rand, (ulong)server_start_time, (ulong)server_start_time / 2); |
| 6279 | 12058 | setup_fpu(); | |
| 6280 | |||
| 6281 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | init_global_table_stats(); |
| 6282 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | init_global_index_stats(); |
| 6283 | |||
| 6284 |
1/2✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
|
12058 | setup_error_log(); // opens the log if needed |
| 6285 | |||
| 6286 | 12056 | enter_cond_hook = thd_enter_cond; | |
| 6287 | 12056 | exit_cond_hook = thd_exit_cond; | |
| 6288 | 12056 | enter_stage_hook = thd_enter_stage; | |
| 6289 | 12056 | set_waiting_for_disk_space_hook = thd_set_waiting_for_disk_space; | |
| 6290 | 12056 | is_killed_hook = thd_killed; | |
| 6291 | |||
| 6292 |
1/2✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
|
12056 | xa::Transaction_cache::initialize(); |
| 6293 | |||
| 6294 | /* | ||
| 6295 | Try to read the previous run's error log and make it available in | ||
| 6296 | performance_schema.error_log. Activate all error logging services | ||
| 6297 | requested by the user in @@global.log_error_services (now that the | ||
| 6298 | component infrastructure is available), flush the buffered error | ||
| 6299 | messages to performance schema and to configured services, and end | ||
| 6300 | error log buffering. | ||
| 6301 | |||
| 6302 | Pre-requisites: | ||
| 6303 | We depend on component_infrastructure_init() and setup_error_log() | ||
| 6304 | above. init_common_variables() additionally gives us a correctly | ||
| 6305 | set up umask etc., and keyring-migration may modify the log-target, | ||
| 6306 | so we wait that out as well. It should be safe to go before the | ||
| 6307 | component-autoload above ("component_urns") for the time being, | ||
| 6308 | but that may not be the case in the future, so we're playing it | ||
| 6309 | safe. Altogether by the time we get here, we're usually within | ||
| 6310 | a second of start-up, with a half-dozen or less messages buffered | ||
| 6311 | if no issues were encountered. | ||
| 6312 | */ | ||
| 6313 |
2/6✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12056 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12056 | if (setup_error_log_components()) unireg_abort(MYSQLD_ABORT_EXIT); |
| 6314 | |||
| 6315 |
2/4✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12056 times.
|
12056 | if (MDL_context_backup_manager::init()) { |
| 6316 | ✗ | LogErr(ERROR_LEVEL, ER_OOM); | |
| 6317 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6318 | } | ||
| 6319 | |||
| 6320 | /* | ||
| 6321 | initialize delegates for extension observers, errors have already | ||
| 6322 | been reported in the function | ||
| 6323 | */ | ||
| 6324 |
2/6✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12056 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12056 | if (delegates_init()) unireg_abort(MYSQLD_ABORT_EXIT); |
| 6325 | |||
| 6326 | /* need to configure logging before initializing storage engines */ | ||
| 6327 |
4/4✓ Branch 0 taken 11408 times.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11407 times.
|
12056 | if (opt_log_replica_updates && !opt_bin_log) { |
| 6328 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(WARNING_LEVEL, ER_NEED_LOG_BIN, "--log-replica-updates"); |
| 6329 | } | ||
| 6330 |
4/4✓ Branch 0 taken 3277 times.
✓ Branch 1 taken 8779 times.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 3117 times.
|
12056 | if (binlog_format_used && !opt_bin_log) |
| 6331 |
8/16✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 160 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 160 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 160 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 160 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 160 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 160 times.
✗ Branch 15 not taken.
|
160 | LogErr(WARNING_LEVEL, ER_NEED_LOG_BIN, "--binlog-format"); |
| 6332 | |||
| 6333 | /* Check that we have not let the format to unspecified at this point */ | ||
| 6334 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12056 times.
|
12056 | assert((uint)global_system_variables.binlog_format <= |
| 6335 | array_elements(binlog_format_names) - 1); | ||
| 6336 | |||
| 6337 | 12056 | opt_server_id_mask = ~ulong(0); | |
| 6338 | 12056 | opt_server_id_mask = | |
| 6339 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12056 times.
|
12056 | (opt_server_id_bits == 32) ? ~ulong(0) : (1 << opt_server_id_bits) - 1; |
| 6340 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12056 times.
|
12056 | if (server_id != (server_id & opt_server_id_mask)) { |
| 6341 | ✗ | LogErr(ERROR_LEVEL, ER_SERVERID_TOO_LARGE); | |
| 6342 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6343 | } | ||
| 6344 | |||
| 6345 |
2/2✓ Branch 0 taken 11446 times.
✓ Branch 1 taken 610 times.
|
12056 | if (opt_bin_log) { |
| 6346 | /* Reports an error and aborts, if the --log-bin's path | ||
| 6347 | is a directory.*/ | ||
| 6348 |
2/2✓ Branch 0 taken 4146 times.
✓ Branch 1 taken 7300 times.
|
11446 | if (opt_bin_logname && |
| 6349 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4146 times.
|
4146 | opt_bin_logname[strlen(opt_bin_logname) - 1] == FN_LIBCHAR) { |
| 6350 | ✗ | LogErr(ERROR_LEVEL, ER_NEED_FILE_INSTEAD_OF_DIR, "--log-bin", | |
| 6351 | opt_bin_logname); | ||
| 6352 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6353 | } | ||
| 6354 | |||
| 6355 | /* Reports an error and aborts, if the --log-bin-index's path | ||
| 6356 | is a directory.*/ | ||
| 6357 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11443 times.
|
11446 | if (opt_binlog_index_name && |
| 6358 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
|
3 | opt_binlog_index_name[strlen(opt_binlog_index_name) - 1] == |
| 6359 | FN_LIBCHAR) { | ||
| 6360 | ✗ | LogErr(ERROR_LEVEL, ER_NEED_FILE_INSTEAD_OF_DIR, "--log-bin-index", | |
| 6361 | opt_binlog_index_name); | ||
| 6362 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6363 | } | ||
| 6364 | |||
| 6365 | char buf[FN_REFLEN]; | ||
| 6366 | const char *ln; | ||
| 6367 |
2/2✓ Branch 0 taken 4195 times.
✓ Branch 1 taken 7251 times.
|
11446 | if (log_bin_supplied) { |
| 6368 | /* | ||
| 6369 | Binary log basename defaults to "`hostname`-bin" name prefix | ||
| 6370 | if --log-bin is used without argument. | ||
| 6371 | */ | ||
| 6372 |
1/2✓ Branch 0 taken 4195 times.
✗ Branch 1 not taken.
|
4195 | ln = mysql_bin_log.generate_name(opt_bin_logname, "-bin", buf); |
| 6373 | } else { | ||
| 6374 | /* | ||
| 6375 | Binary log basename defaults to "binlog" name prefix | ||
| 6376 | if --log-bin is not used. | ||
| 6377 | */ | ||
| 6378 |
1/2✓ Branch 0 taken 7251 times.
✗ Branch 1 not taken.
|
7251 | ln = mysql_bin_log.generate_name(opt_bin_logname, "", buf); |
| 6379 | } | ||
| 6380 | |||
| 6381 |
5/6✓ Branch 0 taken 7300 times.
✓ Branch 1 taken 4146 times.
✓ Branch 2 taken 7300 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✓ Branch 5 taken 7251 times.
|
11446 | if (!opt_bin_logname && !opt_binlog_index_name && log_bin_supplied) { |
| 6382 | /* | ||
| 6383 | User didn't give us info to name the binlog index file. | ||
| 6384 | Picking `hostname`-bin.index like did in 4.x, causes replication to | ||
| 6385 | fail if the hostname is changed later. So, we would like to instead | ||
| 6386 | require a name. But as we don't want to break many existing setups, we | ||
| 6387 | only give warning, not error. | ||
| 6388 | */ | ||
| 6389 |
8/16✓ Branch 0 taken 49 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 49 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 49 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 49 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 49 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 49 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 49 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 49 times.
✗ Branch 15 not taken.
|
49 | LogErr(INFORMATION_LEVEL, ER_LOG_BIN_BETTER_WITH_NAME, ln); |
| 6390 | } | ||
| 6391 |
1/2✓ Branch 0 taken 11446 times.
✗ Branch 1 not taken.
|
11446 | if (ln == buf) { |
| 6392 |
1/2✓ Branch 0 taken 11446 times.
✗ Branch 1 not taken.
|
11446 | my_free(opt_bin_logname); |
| 6393 |
1/2✓ Branch 0 taken 11446 times.
✗ Branch 1 not taken.
|
11446 | opt_bin_logname = my_strdup(key_memory_opt_bin_logname, buf, MYF(0)); |
| 6394 | } | ||
| 6395 | |||
| 6396 | /* | ||
| 6397 | Skip opening the index file if we start with --help. This is necessary | ||
| 6398 | to avoid creating the file in an otherwise empty datadir, which will | ||
| 6399 | cause a succeeding 'mysqld --initialize' to fail. | ||
| 6400 | */ | ||
| 6401 |
3/4✓ Branch 0 taken 11430 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11446 times.
|
22876 | if (!is_help_or_validate_option() && |
| 6402 |
2/4✓ Branch 0 taken 11430 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11430 times.
|
11430 | mysql_bin_log.open_index_file(opt_binlog_index_name, ln, true)) { |
| 6403 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6404 | } | ||
| 6405 | } | ||
| 6406 | |||
| 6407 |
2/2✓ Branch 0 taken 11446 times.
✓ Branch 1 taken 610 times.
|
12056 | if (opt_bin_log) { |
| 6408 | /* | ||
| 6409 | opt_bin_logname[0] needs to be checked to make sure opt binlog name is | ||
| 6410 | not an empty string, in case it is an empty string default file | ||
| 6411 | extension will be passed | ||
| 6412 | */ | ||
| 6413 |
2/2✓ Branch 0 taken 4195 times.
✓ Branch 1 taken 7251 times.
|
11446 | if (log_bin_supplied) { |
| 6414 |
1/2✓ Branch 0 taken 4195 times.
✗ Branch 1 not taken.
|
4195 | log_bin_basename = rpl_make_log_name( |
| 6415 | key_memory_MYSQL_BIN_LOG_basename, opt_bin_logname, | ||
| 6416 | default_logfile_name, | ||
| 6417 |
2/4✓ Branch 0 taken 4195 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4195 times.
✗ Branch 3 not taken.
|
4195 | (opt_bin_logname && opt_bin_logname[0]) ? "" : "-bin"); |
| 6418 | } else { | ||
| 6419 | 7251 | log_bin_basename = | |
| 6420 |
1/2✓ Branch 0 taken 7251 times.
✗ Branch 1 not taken.
|
7251 | rpl_make_log_name(key_memory_MYSQL_BIN_LOG_basename, opt_bin_logname, |
| 6421 | default_binlogfile_name, ""); | ||
| 6422 | } | ||
| 6423 | |||
| 6424 | 11446 | log_bin_index = | |
| 6425 |
1/2✓ Branch 0 taken 11446 times.
✗ Branch 1 not taken.
|
11446 | rpl_make_log_name(key_memory_MYSQL_BIN_LOG_index, opt_binlog_index_name, |
| 6426 | log_bin_basename, ".index"); | ||
| 6427 | |||
| 6428 |
3/4✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11443 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
|
11446 | if ((!opt_binlog_index_name || !opt_binlog_index_name[0]) && |
| 6429 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | log_bin_index) { |
| 6430 | 22886 | strmake(default_binlog_index_name, | |
| 6431 |
2/4✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11443 times.
✗ Branch 3 not taken.
|
11443 | log_bin_index + dirname_length(log_bin_index), |
| 6432 | FN_REFLEN + index_ext_length - 1); | ||
| 6433 | 11443 | opt_binlog_index_name = default_binlog_index_name; | |
| 6434 | } | ||
| 6435 | |||
| 6436 |
2/4✓ Branch 0 taken 11446 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11446 times.
|
11446 | if (log_bin_basename == nullptr || log_bin_index == nullptr) { |
| 6437 | ✗ | LogErr(ERROR_LEVEL, ER_RPL_CANT_MAKE_PATHS, (int)FN_REFLEN, (int)FN_LEN); | |
| 6438 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6439 | } | ||
| 6440 | } | ||
| 6441 | |||
| 6442 |
3/8✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12056 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12056 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
12056 | DBUG_PRINT("debug", |
| 6443 | ("opt_bin_logname: %s, opt_relay_logname: %s, pidfile_name: %s", | ||
| 6444 | opt_bin_logname, opt_relay_logname, pidfile_name)); | ||
| 6445 | |||
| 6446 | /* | ||
| 6447 | opt_relay_logname[0] needs to be checked to make sure opt relaylog name is | ||
| 6448 | not an empty string, in case it is an empty string default file | ||
| 6449 | extension will be passed | ||
| 6450 | */ | ||
| 6451 |
1/2✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
|
12056 | relay_log_basename = rpl_make_log_name( |
| 6452 | key_memory_MYSQL_RELAY_LOG_basename, opt_relay_logname, | ||
| 6453 | default_logfile_name, | ||
| 6454 |
3/4✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 8872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3184 times.
|
12056 | (opt_relay_logname && opt_relay_logname[0]) ? "" : relay_ext); |
| 6455 | |||
| 6456 |
3/4✓ Branch 0 taken 3184 times.
✓ Branch 1 taken 8872 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3184 times.
|
12056 | if (!opt_relay_logname || !opt_relay_logname[0]) { |
| 6457 |
1/2✓ Branch 0 taken 8872 times.
✗ Branch 1 not taken.
|
8872 | if (relay_log_basename) { |
| 6458 | 17744 | strmake(default_relaylogfile_name, | |
| 6459 |
2/4✓ Branch 0 taken 8872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8872 times.
✗ Branch 3 not taken.
|
8872 | relay_log_basename + dirname_length(relay_log_basename), |
| 6460 | FN_REFLEN + relay_ext_length - 1); | ||
| 6461 | 8872 | opt_relay_logname = default_relaylogfile_name; | |
| 6462 | } | ||
| 6463 | } else | ||
| 6464 | 3184 | opt_relay_logname_supplied = true; | |
| 6465 | |||
| 6466 |
1/2✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
|
12056 | if (relay_log_basename != nullptr) |
| 6467 |
1/2✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
|
12056 | relay_log_index = rpl_make_log_name(key_memory_MYSQL_RELAY_LOG_index, |
| 6468 | opt_relaylog_index_name, | ||
| 6469 | relay_log_basename, ".index"); | ||
| 6470 | |||
| 6471 |
3/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 12048 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
|
12056 | if (!opt_relaylog_index_name || !opt_relaylog_index_name[0]) { |
| 6472 |
1/2✓ Branch 0 taken 12048 times.
✗ Branch 1 not taken.
|
12048 | if (relay_log_index) { |
| 6473 | 24096 | strmake(default_relaylog_index_name, | |
| 6474 |
2/4✓ Branch 0 taken 12048 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12048 times.
✗ Branch 3 not taken.
|
12048 | relay_log_index + dirname_length(relay_log_index), |
| 6475 | FN_REFLEN + relay_ext_length + index_ext_length - 1); | ||
| 6476 | 12048 | opt_relaylog_index_name = default_relaylog_index_name; | |
| 6477 | } | ||
| 6478 | } else | ||
| 6479 | 8 | opt_relaylog_index_name_supplied = true; | |
| 6480 | |||
| 6481 |
2/4✓ Branch 0 taken 12056 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12056 times.
|
12056 | if (relay_log_basename == nullptr || relay_log_index == nullptr) { |
| 6482 | ✗ | LogErr(ERROR_LEVEL, ER_RPL_CANT_MAKE_PATHS, (int)FN_REFLEN, (int)FN_LEN); | |
| 6483 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6484 | } | ||
| 6485 | |||
| 6486 |
2/2✓ Branch 0 taken 11446 times.
✓ Branch 1 taken 610 times.
|
12056 | if (log_bin_basename != nullptr && |
| 6487 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11444 times.
|
11446 | !strcmp(log_bin_basename, relay_log_basename)) { |
| 6488 | 2 | const int bin_ext_length = 4; | |
| 6489 | char default_binlogfile_name_from_hostname[FN_REFLEN + bin_ext_length]; | ||
| 6490 | /* Generate default bin log file name. */ | ||
| 6491 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | strmake(default_binlogfile_name_from_hostname, default_logfile_name, |
| 6492 | FN_REFLEN - 1); | ||
| 6493 | 2 | strcat(default_binlogfile_name_from_hostname, "-bin"); | |
| 6494 | |||
| 6495 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | if (!default_relaylogfile_name[0]) { |
| 6496 | /* Generate default relay log file name. */ | ||
| 6497 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | strmake(default_relaylogfile_name, default_logfile_name, FN_REFLEN - 1); |
| 6498 | 2 | strcat(default_relaylogfile_name, relay_ext); | |
| 6499 | } | ||
| 6500 | /* | ||
| 6501 | Reports an error and aborts, if the same base name is specified | ||
| 6502 | for both binary and relay logs. | ||
| 6503 | */ | ||
| 6504 |
8/16✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
|
2 | LogErr(ERROR_LEVEL, ER_RPL_CANT_HAVE_SAME_BASENAME, log_bin_basename, |
| 6505 | "--log-bin", default_binlogfile_name, | ||
| 6506 | default_binlogfile_name_from_hostname, "--relay-log", | ||
| 6507 | default_relaylogfile_name); | ||
| 6508 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
2 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 6509 | } | ||
| 6510 | |||
| 6511 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12048 times.
|
12054 | if (global_system_variables.binlog_row_value_options != 0) { |
| 6512 | 6 | const char *msg = nullptr; | |
| 6513 | 6 | longlong err = ER_BINLOG_ROW_VALUE_OPTION_IGNORED; | |
| 6514 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 5 times.
|
6 | if (!opt_bin_log) |
| 6515 | 1 | msg = "the binary log is disabled"; | |
| 6516 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 4 times.
|
5 | else if (global_system_variables.binlog_format == BINLOG_FORMAT_STMT) |
| 6517 | 1 | msg = "binlog_format=STATEMENT"; | |
| 6518 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | else if (log_bin_use_v1_row_events) { |
| 6519 | 1 | msg = "binlog_row_value_options=PARTIAL_JSON"; | |
| 6520 | 1 | err = ER_BINLOG_USE_V1_ROW_EVENTS_IGNORED; | |
| 6521 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | } else if (global_system_variables.binlog_row_image == |
| 6522 | BINLOG_ROW_IMAGE_FULL) { | ||
| 6523 | 1 | msg = "binlog_row_image=FULL"; | |
| 6524 | 1 | err = ER_BINLOG_ROW_VALUE_OPTION_USED_ONLY_FOR_AFTER_IMAGES; | |
| 6525 | } | ||
| 6526 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2 times.
|
6 | if (msg) { |
| 6527 |
2/3✓ Branch 0 taken 3 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
4 | switch (err) { |
| 6528 | 3 | case ER_BINLOG_ROW_VALUE_OPTION_IGNORED: | |
| 6529 | case ER_BINLOG_ROW_VALUE_OPTION_USED_ONLY_FOR_AFTER_IMAGES: | ||
| 6530 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | LogErr(WARNING_LEVEL, err, msg, "PARTIAL_JSON"); |
| 6531 | 3 | break; | |
| 6532 | 1 | case ER_BINLOG_USE_V1_ROW_EVENTS_IGNORED: | |
| 6533 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(WARNING_LEVEL, err, msg); |
| 6534 | 1 | break; | |
| 6535 | ✗ | default: | |
| 6536 | ✗ | assert(0); /* purecov: deadcode */ | |
| 6537 | } | ||
| 6538 | } | ||
| 6539 | } | ||
| 6540 | |||
| 6541 | /* call ha_init_key_cache() on all key caches to init them */ | ||
| 6542 |
1/2✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
|
12054 | process_key_caches(&ha_init_key_cache); |
| 6543 | |||
| 6544 | /* Allow storage engine to give real error messages */ | ||
| 6545 |
2/4✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12054 times.
|
12054 | if (ha_init_errors()) return 1; |
| 6546 | |||
| 6547 |
2/4✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12054 times.
|
12054 | if (gtid_server_init()) { |
| 6548 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_INITIALIZE_GTID); | |
| 6549 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6550 | } | ||
| 6551 | |||
| 6552 |
4/4✓ Branch 0 taken 11406 times.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11404 times.
|
12054 | if (opt_log_replica_updates && replicate_same_server_id) { |
| 6553 |
4/8✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
|
2 | if (opt_bin_log && global_gtid_mode.get() != Gtid_mode::ON) { |
| 6554 | ✗ | LogErr(ERROR_LEVEL, ER_RPL_INFINITY_DENIED); | |
| 6555 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6556 | } else | ||
| 6557 |
8/16✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
|
2 | LogErr(WARNING_LEVEL, ER_RPL_INFINITY_IGNORED); |
| 6558 | } | ||
| 6559 | |||
| 6560 | { | ||
| 6561 | /* | ||
| 6562 | We have to call a function in log_resource.cc, or its references | ||
| 6563 | won't be visible to plugins. | ||
| 6564 | */ | ||
| 6565 | #ifndef NDEBUG | ||
| 6566 | int dummy = | ||
| 6567 | #endif | ||
| 6568 |
1/2✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
|
12054 | Log_resource::dummy_function_to_ensure_we_are_linked_into_the_server(); |
| 6569 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12054 times.
|
12054 | assert(dummy == 1); |
| 6570 | } | ||
| 6571 | |||
| 6572 | /* | ||
| 6573 | We need to initialize the UDF globals early before reading the proc table | ||
| 6574 | and before the server component initialization to allow other components | ||
| 6575 | to register their UDFs at init time and de-register them at deinit time. | ||
| 6576 | */ | ||
| 6577 |
1/2✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
|
12054 | udf_init_globals(); |
| 6578 | |||
| 6579 | /* | ||
| 6580 | Set tc_log to point to TC_LOG_DUMMY early in order to allow plugin_init() | ||
| 6581 | to commit attachable transaction after reading from mysql.plugin table. | ||
| 6582 | If necessary tc_log will be adjusted to point to correct TC_LOG instance | ||
| 6583 | later. | ||
| 6584 | */ | ||
| 6585 | 12054 | tc_log = &tc_log_dummy; | |
| 6586 | |||
| 6587 | /* | ||
| 6588 | Each server should have one UUID. We will create it automatically, if it | ||
| 6589 | does not exist. It should be initialized before opening binlog file. Because | ||
| 6590 | server's uuid will be stored into the new binlog file. | ||
| 6591 | */ | ||
| 6592 |
5/8✓ Branch 0 taken 12036 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 12036 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12036 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 12054 times.
|
12054 | if (!is_help_or_validate_option() && init_server_auto_options()) { |
| 6593 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_CREATE_UUID); | |
| 6594 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6595 | } | ||
| 6596 | |||
| 6597 | /*Load early plugins */ | ||
| 6598 |
4/6✓ Branch 0 taken 18 times.
✓ Branch 1 taken 12036 times.
✓ Branch 2 taken 12054 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12054 times.
|
12054 | if (plugin_register_early_plugins(&remaining_argc, remaining_argv, |
| 6599 | 12054 | (is_help_or_validate_option()) | |
| 6600 | ? PLUGIN_INIT_SKIP_INITIALIZATION | ||
| 6601 | : 0)) { | ||
| 6602 | ✗ | LogErr(ERROR_LEVEL, ER_CANT_INITIALIZE_EARLY_PLUGINS); | |
| 6603 | ✗ | unireg_abort(1); | |
| 6604 | } | ||
| 6605 | |||
| 6606 | /* Load builtin plugins, initialize MyISAM, CSV and InnoDB */ | ||
| 6607 |
3/4✓ Branch 0 taken 12054 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 12036 times.
|
12054 | if (plugin_register_builtin_and_init_core_se(&remaining_argc, |
| 6608 | remaining_argv)) { | ||
| 6609 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (!opt_validate_config) |
| 6610 |
8/16✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 18 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 18 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 18 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 18 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 18 times.
✗ Branch 15 not taken.
|
18 | LogErr(ERROR_LEVEL, ER_CANT_INITIALIZE_BUILTIN_PLUGINS); |
| 6611 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
18 | unireg_abort(1); |
| 6612 | } | ||
| 6613 | |||
| 6614 | /* | ||
| 6615 | Needs to be done before dd::init() which runs DDL commands (for real) | ||
| 6616 | during instance initialization. | ||
| 6617 | */ | ||
| 6618 |
1/2✓ Branch 0 taken 12036 times.
✗ Branch 1 not taken.
|
12036 | init_sql_command_flags(); |
| 6619 | |||
| 6620 | /* | ||
| 6621 | plugin_register_dynamic_and_init_all() needs DD initialized. | ||
| 6622 | Initialize DD to create data directory using current server. | ||
| 6623 | */ | ||
| 6624 |
2/2✓ Branch 0 taken 294 times.
✓ Branch 1 taken 11742 times.
|
12036 | if (opt_initialize) { |
| 6625 |
2/2✓ Branch 0 taken 293 times.
✓ Branch 1 taken 1 times.
|
294 | if (!is_help_or_validate_option()) { |
| 6626 |
3/4✓ Branch 0 taken 293 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 290 times.
|
293 | if (dd::init(dd::enum_dd_init_type::DD_INITIALIZE)) { |
| 6627 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | LogErr(ERROR_LEVEL, ER_DD_INIT_FAILED); |
| 6628 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
3 | unireg_abort(1); |
| 6629 | } | ||
| 6630 | |||
| 6631 |
2/4✓ Branch 0 taken 290 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 290 times.
|
290 | if (dd::init(dd::enum_dd_init_type::DD_INITIALIZE_SYSTEM_VIEWS)) { |
| 6632 | ✗ | LogErr(ERROR_LEVEL, ER_SYSTEM_VIEW_INIT_FAILED); | |
| 6633 | ✗ | unireg_abort(1); | |
| 6634 | } | ||
| 6635 | } | ||
| 6636 | } else { | ||
| 6637 | /* | ||
| 6638 | Initialize DD in case of upgrade and normal normal server restart. | ||
| 6639 | It is detected if we are starting on old data directory or current | ||
| 6640 | data directory. If it is old data directory, DD tables are created. | ||
| 6641 | If server is starting on data directory with DD tables, DD is initialized. | ||
| 6642 | */ | ||
| 6643 |
4/4✓ Branch 0 taken 11725 times.
✓ Branch 1 taken 17 times.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 11629 times.
|
23465 | if (!is_help_or_validate_option() && |
| 6644 |
3/4✓ Branch 0 taken 11723 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✓ Branch 3 taken 11612 times.
|
11725 | dd::init(dd::enum_dd_init_type::DD_RESTART_OR_UPGRADE)) { |
| 6645 |
8/16✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 111 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 111 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 111 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 111 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 111 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 111 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 111 times.
✗ Branch 15 not taken.
|
111 | LogErr(ERROR_LEVEL, ER_DD_INIT_FAILED); |
| 6646 | |||
| 6647 |
3/4✓ Branch 0 taken 111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107 times.
✓ Branch 3 taken 4 times.
|
111 | if (!dd::upgrade::no_server_upgrade_required()) { |
| 6648 | 107 | dd_init_failed_during_upgrade = true; | |
| 6649 | } | ||
| 6650 | |||
| 6651 | /* If clone recovery fails, we rollback the files to previous | ||
| 6652 | dataset and attempt to restart server. */ | ||
| 6653 | 111 | int exit_code = | |
| 6654 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 111 times.
|
111 | clone_recovery_error ? MYSQLD_RESTART_EXIT : MYSQLD_ABORT_EXIT; |
| 6655 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
111 | unireg_abort(exit_code); |
| 6656 | } | ||
| 6657 | } | ||
| 6658 | |||
| 6659 | /* | ||
| 6660 | During plugin initialization, a plugin may expect (depending on what the | ||
| 6661 | plugin actually does) to find a functional server, including: | ||
| 6662 | - mysql system tables | ||
| 6663 | - information schema tables | ||
| 6664 | - performance schema tables | ||
| 6665 | - data dictionary | ||
| 6666 | - components / services, including the registry service | ||
| 6667 | During the server installation, all these parts are not available yet, as | ||
| 6668 | they are created during the installation process with mysqld --initialize. | ||
| 6669 | |||
| 6670 | As a result, plugins are not loaded during mysqld --initialize, so that | ||
| 6671 | the server install can proceed and complete before any plugin is loaded | ||
| 6672 | through any config file or pre-programmed command line. | ||
| 6673 | */ | ||
| 6674 | 11920 | int flags = 0; | |
| 6675 | |||
| 6676 |
2/2✓ Branch 0 taken 307 times.
✓ Branch 1 taken 11613 times.
|
11920 | if (opt_noacl) flags |= PLUGIN_INIT_SKIP_PLUGIN_TABLE; |
| 6677 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 11902 times.
|
11920 | if (is_help_or_validate_option()) |
| 6678 | 18 | flags |= PLUGIN_INIT_SKIP_INITIALIZATION | PLUGIN_INIT_SKIP_PLUGIN_TABLE; | |
| 6679 |
2/2✓ Branch 0 taken 291 times.
✓ Branch 1 taken 11629 times.
|
11920 | if (opt_initialize) flags |= PLUGIN_INIT_SKIP_DYNAMIC_LOADING; |
| 6680 | |||
| 6681 | /* | ||
| 6682 | In the case of upgrade, we need to delay initialization of plugins that | ||
| 6683 | depend on e.g. mysql tables that will be changed during upgrade. | ||
| 6684 | */ | ||
| 6685 |
2/2✓ Branch 0 taken 11612 times.
✓ Branch 1 taken 290 times.
|
23822 | if (!is_help_or_validate_option() && !opt_initialize && |
| 6686 |
7/8✓ Branch 0 taken 11902 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11612 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 176 times.
✓ Branch 5 taken 11436 times.
✓ Branch 6 taken 173 times.
✓ Branch 7 taken 11747 times.
|
23998 | !dd::upgrade::no_server_upgrade_required() && |
| 6687 |
2/2✓ Branch 0 taken 173 times.
✓ Branch 1 taken 3 times.
|
176 | opt_upgrade_mode != UPGRADE_MINIMAL) |
| 6688 | 173 | flags |= PLUGIN_INIT_DELAY_UNTIL_AFTER_UPGRADE; | |
| 6689 | |||
| 6690 | /* | ||
| 6691 | Initialize the cost model, but delete it after the plugins are initialized. | ||
| 6692 | Cost model is needed while dropping and creating pfs tables to | ||
| 6693 | update metadata of referencing views (if there are any). | ||
| 6694 | */ | ||
| 6695 |
1/2✓ Branch 0 taken 11920 times.
✗ Branch 1 not taken.
|
11920 | init_optimizer_cost_module(true); |
| 6696 | { // New scope in which the error handler hook is modified. | ||
| 6697 | 11920 | ErrorHandlerFunctionPointer ehh_val = error_handler_hook; | |
| 6698 | 23810 | auto restore_ehh = create_scope_guard([ehh_val]() { | |
| 6699 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11905 times.
|
11905 | assert(ehh_val == my_message_stderr); |
| 6700 | 11905 | error_handler_hook = ehh_val; | |
| 6701 |
1/2✓ Branch 0 taken 11920 times.
✗ Branch 1 not taken.
|
11920 | }); |
| 6702 | 11920 | error_handler_hook = +[](uint c, const char *s, myf f) { | |
| 6703 |
4/4✓ Branch 0 taken 2655 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 2648 times.
|
2657 | if (c != ER_NO_SUCH_TABLE || strstr(s, "mysql.server_cost") == nullptr) { |
| 6704 | 9 | my_message_stderr(c, s, f); | |
| 6705 | } | ||
| 6706 | 2657 | }; | |
| 6707 |
3/4✓ Branch 0 taken 11920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 11905 times.
|
11920 | if (plugin_register_dynamic_and_init_all(&remaining_argc, remaining_argv, |
| 6708 | flags)) { | ||
| 6709 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | delete_optimizer_cost_module(); |
| 6710 | // Delete all DD tables in case of error in initializing plugins. | ||
| 6711 |
2/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 15 times.
|
15 | if (dd::upgrade_57::in_progress()) |
| 6712 | ✗ | (void)dd::init(dd::enum_dd_init_type::DD_DELETE); | |
| 6713 | |||
| 6714 |
1/2✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
|
15 | if (!opt_validate_config) |
| 6715 |
8/16✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 15 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 15 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 15 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 15 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 15 times.
✗ Branch 15 not taken.
|
15 | LogErr(ERROR_LEVEL, ER_CANT_INITIALIZE_DYNAMIC_PLUGINS); |
| 6716 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
15 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 6717 | } | ||
| 6718 | 11905 | } // End of extra scope where missing server_cost errors are not logged | |
| 6719 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11905 times.
|
11905 | assert(error_handler_hook == my_message_stderr); |
| 6720 | 11905 | dynamic_plugins_are_initialized = | |
| 6721 | true; /* Don't separate from init function */ | ||
| 6722 |
1/2✓ Branch 0 taken 11905 times.
✗ Branch 1 not taken.
|
11905 | delete_optimizer_cost_module(); |
| 6723 | |||
| 6724 | 11905 | LEX_CSTRING plugin_name = {STRING_WITH_LEN("thread_pool")}; | |
| 6725 | 23810 | if (Connection_handler_manager::thread_handling != | |
| 6726 |
4/4✓ Branch 0 taken 11853 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✓ Branch 3 taken 11853 times.
|
23758 | Connection_handler_manager::SCHEDULER_ONE_THREAD_PER_CONNECTION || |
| 6727 |
2/4✓ Branch 0 taken 11853 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11853 times.
|
11853 | plugin_is_ready(plugin_name, MYSQL_DAEMON_PLUGIN)) { |
| 6728 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | auto res_grp_mgr = resourcegroups::Resource_group_mgr::instance(); |
| 6729 |
1/2✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
|
52 | res_grp_mgr->disable_resource_group(); |
| 6730 |
2/4✓ Branch 0 taken 52 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
|
52 | res_grp_mgr->set_unsupport_reason("Thread pool plugin enabled"); |
| 6731 | } | ||
| 6732 | |||
| 6733 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 6734 |
2/2✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 18 times.
|
11905 | /* |
| 6735 | A value of the variable dd_upgrade_flag is reset after | ||
| 6736 | dd::init(dd::enum_dd_init_type::DD_POPULATE_UPGRADE) returned. | ||
| 6737 | So make its copy to call init_pfs_tables() with right argument value later. | ||
| 6738 | */ | ||
| 6739 | bool dd_upgrade_was_initiated = dd::upgrade_57::in_progress(); | ||
| 6740 |
1/2✓ Branch 0 taken 11887 times.
✗ Branch 1 not taken.
|
11887 | #endif |
| 6741 | |||
| 6742 | if (!is_help_or_validate_option() && dd::upgrade_57::in_progress()) { | ||
| 6743 |
7/8✓ Branch 0 taken 11597 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 11597 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11509 times.
✓ Branch 5 taken 88 times.
✓ Branch 6 taken 414 times.
✓ Branch 7 taken 11473 times.
|
23396 | // Populate DD tables with meta data from 5.7 |
| 6744 |
2/2✓ Branch 0 taken 36 times.
✓ Branch 1 taken 11473 times.
|
11509 | if (dd::init(dd::enum_dd_init_type::DD_POPULATE_UPGRADE)) { |
| 6745 |
1/2✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
|
414 | LogErr(ERROR_LEVEL, ER_DD_POPULATING_TABLES_FAILED); |
| 6746 | unireg_abort(1); | ||
| 6747 | } | ||
| 6748 |
1/2✓ Branch 0 taken 11473 times.
✗ Branch 1 not taken.
|
11473 | // Run after_dd_upgrade hook |
| 6749 | if (RUN_HOOK(server_state, after_dd_upgrade_from_57, (nullptr))) | ||
| 6750 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6751 | } | ||
| 6752 |
1/2✓ Branch 0 taken 11887 times.
✗ Branch 1 not taken.
|
11887 | |
| 6753 | /* | ||
| 6754 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11887 times.
|
11887 | Store server and plugin IS tables metadata into new DD. |
| 6755 | ✗ | This is done after all the plugins are registered. | |
| 6756 | ✗ | */ | |
| 6757 | if (!is_help_or_validate_option() && !opt_initialize && | ||
| 6758 | !dd::upgrade_57::in_progress() && | ||
| 6759 | dd::init(dd::enum_dd_init_type::DD_UPDATE_I_S_METADATA)) { | ||
| 6760 | LogErr(ERROR_LEVEL, ER_DD_UPDATING_PLUGIN_MD_FAILED); | ||
| 6761 |
7/8✓ Branch 0 taken 11887 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11887 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 88 times.
✓ Branch 5 taken 11799 times.
✓ Branch 6 taken 88 times.
✓ Branch 7 taken 11817 times.
|
11905 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 6762 | } | ||
| 6763 |
3/4✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 72 times.
|
88 | |
| 6764 |
8/16✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
|
16 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE |
| 6765 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
16 | if (!is_help_or_validate_option()) { |
| 6766 | /* | ||
| 6767 | Initialize the cost model, but delete it after the pfs is initialized. | ||
| 6768 |
3/8✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 72 times.
|
72 | Cost model is needed while dropping and creating pfs tables to |
| 6769 | ✗ | update metadata of referencing views (if there are any). | |
| 6770 | */ | ||
| 6771 | init_optimizer_cost_module(true); | ||
| 6772 | |||
| 6773 | bool st; | ||
| 6774 | if (opt_initialize || dd_upgrade_was_initiated || | ||
| 6775 | opt_upgrade_mode == UPGRADE_FORCE) | ||
| 6776 |
2/2✓ Branch 0 taken 11581 times.
✓ Branch 1 taken 290 times.
|
23760 | st = dd::performance_schema::init_pfs_tables( |
| 6777 |
5/8✓ Branch 0 taken 11871 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11581 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11581 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11889 times.
|
35341 | dd::enum_dd_init_type::DD_INITIALIZE); |
| 6778 |
2/4✓ Branch 0 taken 11581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11581 times.
|
11581 | else |
| 6779 | ✗ | st = dd::performance_schema::init_pfs_tables( | |
| 6780 | ✗ | dd::enum_dd_init_type::DD_RESTART_OR_UPGRADE); | |
| 6781 | |||
| 6782 | /* Now that the pfs is initialized, delete the cost model. */ | ||
| 6783 |
1/2✓ Branch 0 taken 11889 times.
✗ Branch 1 not taken.
|
11889 | delete_optimizer_cost_module(); |
| 6784 |
6/6✓ Branch 0 taken 11871 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11581 times.
✓ Branch 3 taken 290 times.
✓ Branch 4 taken 160 times.
✓ Branch 5 taken 11729 times.
|
23470 | |
| 6785 |
3/4✓ Branch 0 taken 11581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 160 times.
✓ Branch 3 taken 11421 times.
|
11581 | if (st) { |
| 6786 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 157 times.
|
160 | LogErr(ERROR_LEVEL, ER_PERFSCHEMA_TABLES_INIT_FAILED); |
| 6787 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | unireg_abort(1); |
| 6788 | } | ||
| 6789 |
1/2✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
|
157 | } |
| 6790 |
2/4✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
|
157 | #endif |
| 6791 | |||
| 6792 | bool recreate_non_dd_based_system_view = dd::upgrade::I_S_upgrade_required(); | ||
| 6793 | ✗ | if (!is_help_or_validate_option() && !opt_initialize && | |
| 6794 | ✗ | !dd::upgrade::no_server_upgrade_required()) { | |
| 6795 | if (opt_upgrade_mode == UPGRADE_MINIMAL) | ||
| 6796 |
1/2✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
|
157 | LogErr(WARNING_LEVEL, ER_SERVER_UPGRADE_SKIP); |
| 6797 | 157 | else { | |
| 6798 | init_optimizer_cost_module(true); | ||
| 6799 | if (bootstrap::run_bootstrap_thread(nullptr, nullptr, | ||
| 6800 | &dd::upgrade::upgrade_system_schemas, | ||
| 6801 | SYSTEM_THREAD_SERVER_UPGRADE)) { | ||
| 6802 | LogErr(ERROR_LEVEL, ER_SERVER_UPGRADE_FAILED); | ||
| 6803 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6804 | } | ||
| 6805 | delete_optimizer_cost_module(); | ||
| 6806 | recreate_non_dd_based_system_view = true; | ||
| 6807 | |||
| 6808 |
2/4✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
|
157 | /* |
| 6809 | ✗ | When upgrade is finished, we need to initialize the plugins that | |
| 6810 | had their initialization delayed due to dependencies on the | ||
| 6811 | environment. | ||
| 6812 | |||
| 6813 | TODO: Provide a better long term solution by re-ordering startup | ||
| 6814 | sequence and rewriting the way we create and upgrade server | ||
| 6815 | resources needed by plugins. | ||
| 6816 | */ | ||
| 6817 | if (dd::upgrade::plugin_initialize_delayed_after_upgrade()) { | ||
| 6818 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6819 | } | ||
| 6820 |
2/2✓ Branch 0 taken 11581 times.
✓ Branch 1 taken 290 times.
|
23760 | } |
| 6821 |
8/8✓ Branch 0 taken 11871 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11578 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 157 times.
✓ Branch 5 taken 11421 times.
✓ Branch 6 taken 157 times.
✓ Branch 7 taken 11732 times.
|
23760 | } |
| 6822 | |||
| 6823 |
2/4✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 157 times.
|
157 | /* |
| 6824 | Re-create non DD based system views after a) if we upgraded system | ||
| 6825 | ✗ | schemas b) I_S system view version is changed and server system views | |
| 6826 | ✗ | were recreated. c) If the database was upgraded. We do not update this | |
| 6827 | in upgrade-minimal mode. | ||
| 6828 | */ | ||
| 6829 | if (!is_help_or_validate_option() && !opt_initialize && | ||
| 6830 |
1/2✓ Branch 0 taken 11889 times.
✗ Branch 1 not taken.
|
11889 | opt_upgrade_mode != UPGRADE_MINIMAL && |
| 6831 | recreate_non_dd_based_system_view) { | ||
| 6832 |
6/6✓ Branch 0 taken 11871 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 11581 times.
✓ Branch 3 taken 290 times.
✓ Branch 4 taken 11581 times.
✓ Branch 5 taken 308 times.
|
11889 | if (dd::init( |
| 6833 |
2/4✓ Branch 0 taken 11581 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11581 times.
|
11581 | dd::enum_dd_init_type::DD_INITIALIZE_NON_DD_BASED_SYSTEM_VIEWS)) { |
| 6834 | ✗ | LogErr(ERROR_LEVEL, ER_SYSTEM_VIEW_INIT_FAILED); | |
| 6835 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6836 | } | ||
| 6837 | } | ||
| 6838 | |||
| 6839 | auto res_grp_mgr = resourcegroups::Resource_group_mgr::instance(); | ||
| 6840 | // Initialize the Resource group subsystem. | ||
| 6841 | if (!is_help_or_validate_option() && !opt_initialize) { | ||
| 6842 | 11889 | if (res_grp_mgr->post_init()) { | |
| 6843 |
1/2✓ Branch 0 taken 11889 times.
✗ Branch 1 not taken.
|
11889 | LogErr(ERROR_LEVEL, ER_RESOURCE_GROUP_POST_INIT_FAILED); |
| 6844 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6845 | 11889 | } | |
| 6846 | 11889 | } | |
| 6847 | 11889 | ||
| 6848 |
2/4✓ Branch 0 taken 11889 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11889 times.
|
11889 | Session_tracker session_track_system_variables_check; |
| 6849 | LEX_STRING var_list; | ||
| 6850 | ✗ | char *tmp_str; | |
| 6851 | ✗ | size_t len = strlen(global_system_variables.track_sysvars_ptr); | |
| 6852 | ✗ | tmp_str = (char *)my_malloc(PSI_NOT_INSTRUMENTED, len * sizeof(char) + 2, | |
| 6853 | MYF(MY_WME)); | ||
| 6854 |
2/4✓ Branch 0 taken 11889 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11889 times.
✗ Branch 3 not taken.
|
11889 | strcpy(tmp_str, global_system_variables.track_sysvars_ptr); |
| 6855 | var_list.length = len; | ||
| 6856 | var_list.str = tmp_str; | ||
| 6857 |
3/4✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11884 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
11889 | if (session_track_system_variables_check.server_boot_verify( |
| 6858 | 5 | system_charset_info, var_list)) { | |
| 6859 | 5 | LogErr(ERROR_LEVEL, ER_TRACK_VARIABLES_BOGUS); | |
| 6860 | if (tmp_str) my_free(tmp_str); | ||
| 6861 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6862 | } | ||
| 6863 | 5 | if (tmp_str) my_free(tmp_str); | |
| 6864 | |||
| 6865 |
3/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 3 times.
|
5 | // Validate the configuration if --validate-config was specified. |
| 6866 | if (opt_validate_config && (remaining_argc > 1)) { | ||
| 6867 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
2 | bool saved_getopt_skip_unknown = my_getopt_skip_unknown; |
| 6868 | 3 | struct my_option no_opts[] = {{nullptr, 0, nullptr, nullptr, nullptr, | |
| 6869 | nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, | ||
| 6870 | nullptr, 0, nullptr}}; | ||
| 6871 |
2/4✓ Branch 0 taken 16 times.
✓ Branch 1 taken 11871 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11887 | |
| 6872 | my_getopt_skip_unknown = false; | ||
| 6873 | |||
| 6874 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11871 times.
|
11871 | if (handle_options(&remaining_argc, &remaining_argv, no_opts, |
| 6875 | ✗ | mysqld_get_one_option)) | |
| 6876 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 6877 | my_getopt_skip_unknown = saved_getopt_skip_unknown; | ||
| 6878 | } | ||
| 6879 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11866 times.
|
11871 | |
| 6880 | if (is_help_or_validate_option()) unireg_abort(MYSQLD_SUCCESS_EXIT); | ||
| 6881 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
|
5 | |
| 6882 | ✗ | /* if the errmsg.sys is not loaded, terminate to maintain behaviour */ | |
| 6883 | if (!my_default_lc_messages->errmsgs->is_loaded()) { | ||
| 6884 | LogErr(ERROR_LEVEL, ER_CANT_READ_ERRMSGS); | ||
| 6885 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6886 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | } |
| 6887 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | |
| 6888 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
5 | if (opt_libcoredumper) { |
| 6889 | #if HAVE_LIBCOREDUMPER | ||
| 6890 | if (opt_corefile) { | ||
| 6891 | sql_print_warning( | ||
| 6892 | "Started with --core-file and --coredumper. " | ||
| 6893 | "--coredumper will take precedence."); | ||
| 6894 | } | ||
| 6895 | if (opt_libcoredumper_path != NULL) { | ||
| 6896 | if (!validate_libcoredumper_path(opt_libcoredumper_path)) { | ||
| 6897 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6898 | } | ||
| 6899 |
2/4✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11866 times.
|
11866 | } |
| 6900 | ✗ | #else | |
| 6901 | ✗ | sql_print_warning( | |
| 6902 | "This version of MySQL has not been compiled with " | ||
| 6903 | "libcoredumper support, ignoring --coredumper argument"); | ||
| 6904 | #endif | ||
| 6905 |
2/4✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11866 times.
|
11866 | } |
| 6906 | ✗ | ||
| 6907 | ✗ | /* We have to initialize the storage engines before CSV logging */ | |
| 6908 | if (ha_init()) { | ||
| 6909 | LogErr(ERROR_LEVEL, ER_CANT_INIT_DBS); | ||
| 6910 |
2/2✓ Branch 0 taken 290 times.
✓ Branch 1 taken 11576 times.
|
11866 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 6911 | } | ||
| 6912 | |||
| 6913 | /* Initialize ndbinfo tables in DD */ | ||
| 6914 | if (dd::ndbinfo::init_schema_and_tables(opt_upgrade_mode)) { | ||
| 6915 | LogErr(ERROR_LEVEL, ER_NDBINFO_UPGRADING_SCHEMA_FAIL); | ||
| 6916 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11866 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11866 | unireg_abort(1); |
| 6917 | ✗ | } | |
| 6918 | |||
| 6919 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11865 times.
|
11866 | if (opt_initialize) log_output_options = LOG_FILE; |
| 6920 | |||
| 6921 | 1 | /* | |
| 6922 |
2/4✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
|
1 | Issue a warning if there were specified additional options to the |
| 6923 | ✗ | log-output along with NONE. Probably this wasn't what user wanted. | |
| 6924 | ✗ | */ | |
| 6925 | if ((log_output_options & LOG_NONE) && (log_output_options & ~LOG_NONE)) | ||
| 6926 | LogErr(WARNING_LEVEL, ER_LOG_OUTPUT_CONTRADICTORY); | ||
| 6927 | |||
| 6928 |
1/2✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
|
11866 | if (log_output_options & LOG_TABLE) { |
| 6929 | /* Fall back to log files if the csv engine is not loaded. */ | ||
| 6930 | LEX_CSTRING csv_name = {STRING_WITH_LEN("csv")}; | ||
| 6931 |
1/2✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
|
11866 | if (!plugin_is_ready(csv_name, MYSQL_STORAGE_ENGINE_PLUGIN)) { |
| 6932 |
7/8✓ Branch 0 taken 11433 times.
✓ Branch 1 taken 433 times.
✓ Branch 2 taken 11433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 11432 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 11865 times.
|
11866 | LogErr(ERROR_LEVEL, ER_NO_CSV_NO_LOG_TABLES); |
| 6933 | 1 | log_output_options = (log_output_options & ~LOG_TABLE) | LOG_FILE; | |
| 6934 | } | ||
| 6935 | } | ||
| 6936 |
1/2✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
|
11866 | |
| 6937 |
7/8✓ Branch 0 taken 11433 times.
✓ Branch 1 taken 433 times.
✓ Branch 2 taken 11433 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 11432 times.
✓ Branch 6 taken 1 times.
✓ Branch 7 taken 11865 times.
|
11866 | query_logger.set_handlers(log_output_options); |
| 6938 | 1 | ||
| 6939 | // Open slow log file if enabled. | ||
| 6940 | query_logger.set_log_file(QUERY_LOG_SLOW); | ||
| 6941 | if (opt_slow_log && query_logger.reopen_log_file(QUERY_LOG_SLOW)) | ||
| 6942 | opt_slow_log = false; | ||
| 6943 |
2/4✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11866 times.
|
11866 | |
| 6944 | // Open general log file if enabled. | ||
| 6945 | ✗ | query_logger.set_log_file(QUERY_LOG_GENERAL); | |
| 6946 |
2/4✓ Branch 0 taken 11866 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11866 times.
|
11866 | if (opt_general_log && query_logger.reopen_log_file(QUERY_LOG_GENERAL)) |
| 6947 | opt_general_log = false; | ||
| 6948 | ✗ | ||
| 6949 | /* | ||
| 6950 |
4/4✓ Branch 0 taken 11576 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 11562 times.
✓ Branch 3 taken 14 times.
|
11866 | Set the default storage engines |
| 6951 |
1/2✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
|
11562 | */ |
| 6952 | if (initialize_storage_engine(default_storage_engine, "", | ||
| 6953 | &global_system_variables.table_plugin)) | ||
| 6954 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 6955 | 11562 | if (initialize_storage_engine(default_tmp_storage_engine, " temp", | |
| 6956 |
3/4✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 11558 times.
|
11562 | &global_system_variables.temp_table_plugin)) |
| 6957 |
8/16✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 6958 | |||
| 6959 | if (!opt_initialize && !opt_noacl) { | ||
| 6960 | set_externally_disabled_storage_engine_names(opt_disabled_storage_engines); | ||
| 6961 | |||
| 6962 | 11562 | // Log warning if default_storage_engine is a disabled storage engine. | |
| 6963 |
3/4✓ Branch 0 taken 11562 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 11558 times.
|
11562 | handlerton *default_se_handle = |
| 6964 |
8/16✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | plugin_data<handlerton *>(global_system_variables.table_plugin); |
| 6965 | if (ha_is_storage_engine_disabled(default_se_handle)) | ||
| 6966 | LogErr(WARNING_LEVEL, ER_DISABLED_STORAGE_ENGINE_AS_DEFAULT, | ||
| 6967 | "default_storage_engine", default_storage_engine); | ||
| 6968 | |||
| 6969 | // Log warning if default_tmp_storage_engine is a disabled storage engine. | ||
| 6970 | handlerton *default_tmp_se_handle = | ||
| 6971 |
4/6✓ Branch 0 taken 5 times.
✓ Branch 1 taken 11861 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
|
11866 | plugin_data<handlerton *>(global_system_variables.temp_table_plugin); |
| 6972 | if (ha_is_storage_engine_disabled(default_tmp_se_handle)) | ||
| 6973 | 5 | LogErr(WARNING_LEVEL, ER_DISABLED_STORAGE_ENGINE_AS_DEFAULT, | |
| 6974 | "default_tmp_storage_engine", default_tmp_storage_engine); | ||
| 6975 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | } |
| 6976 | 5 | ||
| 6977 | /* | ||
| 6978 | 5 | Validate any enforced storage engine | |
| 6979 | */ | ||
| 6980 | if (enforce_storage_engine && !opt_initialize && !opt_noacl) { | ||
| 6981 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
5 | const LEX_CSTRING name{enforce_storage_engine, |
| 6982 | 5 | strlen(enforce_storage_engine)}; | |
| 6983 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | plugin_ref plugin; |
| 6984 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | if ((plugin = ha_resolve_by_name(nullptr, &name, false))) { |
| 6985 | handlerton *hton = plugin_data<handlerton *>(plugin); | ||
| 6986 | const LEX_CSTRING defname{default_storage_engine, | ||
| 6987 | strlen(default_storage_engine)}; | ||
| 6988 | plugin_ref defplugin; | ||
| 6989 | handlerton *defhton; | ||
| 6990 |
3/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
|
5 | if ((defplugin = ha_resolve_by_name(nullptr, &defname, false))) { |
| 6991 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | defhton = plugin_data<handlerton *>(defplugin); |
| 6992 | if (defhton != hton) { | ||
| 6993 | sql_print_warning( | ||
| 6994 | "Default storage engine (%s)" | ||
| 6995 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | " is not the same as enforced storage engine (%s)", |
| 6996 | default_storage_engine, enforce_storage_engine); | ||
| 6997 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | } |
| 6998 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | } |
| 6999 | if (ha_is_storage_engine_disabled(hton)) { | ||
| 7000 | ✗ | sql_print_error( | |
| 7001 | "enforced storage engine %s is among disabled storage " | ||
| 7002 | ✗ | "engines", | |
| 7003 | enforce_storage_engine); | ||
| 7004 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7005 | } | ||
| 7006 |
3/4✓ Branch 0 taken 11865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11864 times.
|
11865 | plugin_unlock(nullptr, defplugin); |
| 7007 |
4/6✓ Branch 0 taken 540 times.
✓ Branch 1 taken 11325 times.
✓ Branch 2 taken 540 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 540 times.
|
11865 | plugin_unlock(nullptr, plugin); |
| 7008 |
2/2✓ Branch 0 taken 11321 times.
✓ Branch 1 taken 4 times.
|
11325 | } else { |
| 7009 | 11321 | sql_print_error("Unknown/unsupported storage engine: %s", | |
| 7010 | enforce_storage_engine); | ||
| 7011 | 4 | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 7012 | } | ||
| 7013 | } | ||
| 7014 |
2/4✓ Branch 0 taken 11865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11865 times.
|
11865 | |
| 7015 | ✗ | DBUG_EXECUTE_IF("total_ha_2pc_equals_2", total_ha_2pc = 2;); | |
| 7016 | ✗ | if (total_ha_2pc > 1 || (1 == total_ha_2pc && opt_bin_log)) { | |
| 7017 | if (opt_bin_log) | ||
| 7018 | tc_log = &mysql_bin_log; | ||
| 7019 |
4/6✓ Branch 0 taken 11865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1514 times.
✓ Branch 3 taken 10351 times.
✓ Branch 4 taken 1514 times.
✗ Branch 5 not taken.
|
11865 | else |
| 7020 |
5/6✓ Branch 0 taken 11321 times.
✓ Branch 1 taken 544 times.
✓ Branch 2 taken 11865 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✓ Branch 5 taken 11787 times.
|
11865 | tc_log = &tc_log_mmap; |
| 7021 |
8/16✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 78 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 78 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 78 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 78 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 78 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 78 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 78 times.
✗ Branch 15 not taken.
|
78 | } |
| 7022 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
78 | |
| 7023 | if (Recovered_xa_transactions::init()) { | ||
| 7024 | LogErr(ERROR_LEVEL, ER_OOM); | ||
| 7025 |
2/4✓ Branch 0 taken 11787 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11787 times.
|
11787 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 7026 | ✗ | } | |
| 7027 | |||
| 7028 |
1/2✓ Branch 0 taken 11785 times.
✗ Branch 1 not taken.
|
11787 | RUN_HOOK(server_state, before_recovery, (nullptr)); |
| 7029 | if (tc_log->open(opt_bin_log ? opt_bin_logname : opt_tc_log_file)) { | ||
| 7030 | LogErr(ERROR_LEVEL, ER_CANT_INIT_TC_LOG); | ||
| 7031 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7032 | } | ||
| 7033 | |||
| 7034 | if (dd::reset_tables_and_tablespaces()) { | ||
| 7035 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7036 | } | ||
| 7037 |
1/2✓ Branch 0 taken 11785 times.
✗ Branch 1 not taken.
|
11785 | ha_post_recover(); |
| 7038 |
2/4✓ Branch 0 taken 11785 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11785 times.
|
11785 | |
| 7039 | ✗ | /* | |
| 7040 | Add prepared XA transactions into the cache of XA transactions and acquire | ||
| 7041 | mdl lock for every table involved in any of these prepared XA transactions. | ||
| 7042 |
5/6✓ Branch 0 taken 11785 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2203 times.
✓ Branch 3 taken 9582 times.
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 11782 times.
|
13988 | This step moved away from the function ha_recover() in order to avoid |
| 7043 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 2200 times.
|
2203 | possible suspending on acquiring EXCLUSIVE mdl lock on tables inside the |
| 7044 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | function dd::reset_tables_and_tablespaces() when table cache being reset. |
| 7045 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
3 | */ |
| 7046 | if (Recovered_xa_transactions::instance() | ||
| 7047 | .recover_prepared_xa_transactions()) { | ||
| 7048 |
3/4✓ Branch 0 taken 11782 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 11770 times.
|
11782 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 7049 |
8/16✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 12 times.
✗ Branch 15 not taken.
|
12 | } |
| 7050 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
12 | |
| 7051 | if (global_gtid_mode.get() == Gtid_mode::ON && | ||
| 7052 | _gtid_consistency_mode != GTID_CONSISTENCY_MODE_ON) { | ||
| 7053 |
7/8✓ Branch 0 taken 11770 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 65 times.
✓ Branch 3 taken 11705 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 61 times.
✓ Branch 6 taken 4 times.
✓ Branch 7 taken 11766 times.
|
11770 | LogErr(ERROR_LEVEL, ER_RPL_GTID_MODE_REQUIRES_ENFORCE_GTID_CONSISTENCY_ON); |
| 7054 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 7055 | } | ||
| 7056 | |||
| 7057 | if (rpl_encryption.initialize()) { | ||
| 7058 | LogErr(ERROR_LEVEL, ER_SERVER_RPL_ENCRYPTION_UNABLE_TO_INITIALIZE); | ||
| 7059 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7060 |
2/2✓ Branch 0 taken 11226 times.
✓ Branch 1 taken 544 times.
|
11770 | } |
| 7061 | |||
| 7062 | if (rpl_encryption.is_enabled() && !opt_bin_log) { | ||
| 7063 | sql_print_information( | ||
| 7064 | "binlog and relay log encryption enabled without binary logging being " | ||
| 7065 | "enabled. " | ||
| 7066 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11226 times.
|
11226 | "If relay logs are in use, they will be encrypted."); |
| 7067 | 11226 | } | |
| 7068 |
1/2✓ Branch 0 taken 11226 times.
✗ Branch 1 not taken.
|
11226 | |
| 7069 | if (opt_bin_log) { | ||
| 7070 |
3/4✓ Branch 0 taken 11226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11224 times.
|
11226 | /* |
| 7071 | Configures what object is used by the current log to store processed | ||
| 7072 | gtid(s). This is necessary in the MYSQL_BIN_LOG::MYSQL_BIN_LOG to | ||
| 7073 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | correctly compute the set of previous gtids. |
| 7074 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
2 | */ |
| 7075 | assert(!mysql_bin_log.is_relay_log); | ||
| 7076 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | mysql_mutex_t *log_lock = mysql_bin_log.get_log_lock(); |
| 7077 | mysql_mutex_lock(log_lock); | ||
| 7078 | |||
| 7079 | if (mysql_bin_log.open_binlog(opt_bin_logname, nullptr, max_binlog_size, | ||
| 7080 | false, true /*need_lock_index=true*/, | ||
| 7081 | true /*need_sid_lock=true*/, nullptr)) { | ||
| 7082 | mysql_mutex_unlock(log_lock); | ||
| 7083 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7084 | } | ||
| 7085 |
4/4✓ Branch 0 taken 22 times.
✓ Branch 1 taken 11746 times.
✓ Branch 2 taken 14 times.
✓ Branch 3 taken 8 times.
|
11768 | mysql_mutex_unlock(log_lock); |
| 7086 |
4/4✓ Branch 0 taken 8 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 5 times.
|
14 | } |
| 7087 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | |
| 7088 | 3 | /* | |
| 7089 | When we pass non-zero values for both expire_logs_days and | ||
| 7090 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 11746 times.
|
11754 | binlog_expire_logs_seconds at the server start-up, the value of |
| 7091 | 8 | expire_logs_days will be ignored and only binlog_expire_logs_seconds | |
| 7092 |
3/4✓ Branch 0 taken 7 times.
✓ Branch 1 taken 11761 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
|
11768 | will be used. |
| 7093 | */ | ||
| 7094 |
2/2✓ Branch 0 taken 544 times.
✓ Branch 1 taken 11224 times.
|
11768 | if (binlog_expire_logs_seconds_supplied && expire_logs_days_supplied) { |
| 7095 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 537 times.
|
544 | if (binlog_expire_logs_seconds != 0 && expire_logs_days != 0) { |
| 7096 |
8/16✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | LogErr(WARNING_LEVEL, ER_EXPIRE_LOGS_DAYS_IGNORED); |
| 7097 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 538 times.
|
544 | expire_logs_days = 0; |
| 7098 |
8/16✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
|
6 | } |
| 7099 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
|
544 | } else if (expire_logs_days_supplied) |
| 7100 | ✗ | binlog_expire_logs_seconds = 0; | |
| 7101 | assert(expire_logs_days == 0 || binlog_expire_logs_seconds == 0); | ||
| 7102 | |||
| 7103 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11768 | if (!opt_bin_log) { |
| 7104 | if (binlog_expire_logs_seconds_supplied) | ||
| 7105 | LogErr(WARNING_LEVEL, ER_NEED_LOG_BIN, "--binlog-expire-logs-seconds"); | ||
| 7106 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 11768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11768 times.
|
11768 | if (expire_logs_days_supplied) |
| 7107 | ✗ | LogErr(WARNING_LEVEL, ER_NEED_LOG_BIN, "--expire_logs_days"); | |
| 7108 | ✗ | if (binlog_space_limit) | |
| 7109 | ✗ | LogErr(WARNING_LEVEL, ER_NEED_LOG_BIN, "--binlog-space-limit"); | |
| 7110 | } | ||
| 7111 | ✗ | ||
| 7112 | ✗ | if (opt_myisam_log) (void)mi_log(1); | |
| 7113 | |||
| 7114 | ✗ | #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) | |
| 7115 | if (locked_in_memory && !getuid()) { | ||
| 7116 | if (setreuid((uid_t)-1, 0) == -1) { // this should never happen | ||
| 7117 | ✗ | LogErr(ERROR_LEVEL, ER_FAIL_SETREUID, strerror(errno)); | |
| 7118 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7119 | } | ||
| 7120 | if (mlockall(MCL_CURRENT)) { | ||
| 7121 | 11768 | LogErr(WARNING_LEVEL, ER_FAILED_TO_LOCK_MEM, | |
| 7122 | errno); /* purecov: inspected */ | ||
| 7123 |
2/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11768 times.
✗ Branch 3 not taken.
|
11768 | locked_in_memory = false; |
| 7124 |
2/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11768 times.
|
11768 | } |
| 7125 | ✗ | #ifndef _WIN32 | |
| 7126 | if (!user_info.IsVoid()) set_user(mysqld_user, user_info); | ||
| 7127 |
2/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11768 times.
✗ Branch 3 not taken.
|
11768 | #endif |
| 7128 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | } else |
| 7129 | #endif | ||
| 7130 | locked_in_memory = false; | ||
| 7131 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | |
| 7132 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | rpl_acf_configuration_handler = new Rpl_acf_configuration_handler(); |
| 7133 | if (rpl_acf_configuration_handler->init()) { | ||
| 7134 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 7135 | } | ||
| 7136 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | rpl_source_io_monitor = new Source_IO_monitor(); |
| 7137 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | udf_load_service.init(); |
| 7138 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | |
| 7139 | /* Initialize the optimizer cost module */ | ||
| 7140 | init_optimizer_cost_module(true); | ||
| 7141 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | ft_init_stopwords(); |
| 7142 | |||
| 7143 | init_max_user_conn(); | ||
| 7144 | 11768 | ||
| 7145 | 11768 | init_global_user_stats(); | |
| 7146 | init_global_client_stats(); | ||
| 7147 | init_global_thread_stats(); | ||
| 7148 | |||
| 7149 | #if defined(MYSQL_ICU_DATADIR) | ||
| 7150 | init_icu_data_directory(); | ||
| 7151 | #endif // MYSQL_ICU_DATADIR | ||
| 7152 | |||
| 7153 | return 0; | ||
| 7154 | } | ||
| 7155 | |||
| 7156 | #ifdef _WIN32 | ||
| 7157 | |||
| 7158 | extern "C" void *handle_shutdown_and_restart(void *arg) { | ||
| 7159 | MSG msg; | ||
| 7160 | HANDLE event_handles[2]; | ||
| 7161 | event_handles[0] = hEventShutdown; | ||
| 7162 | event_handles[1] = hEventRestart; | ||
| 7163 | |||
| 7164 | my_thread_init(); | ||
| 7165 | /* This call should create the message queue for this thread. */ | ||
| 7166 | PeekMessage(&msg, NULL, 1, 65534, PM_NOREMOVE); | ||
| 7167 | DWORD ret_code = WaitForMultipleObjects( | ||
| 7168 | 2, static_cast<HANDLE *>(event_handles), FALSE, INFINITE); | ||
| 7169 | |||
| 7170 | if (ret_code == WAIT_OBJECT_0 || ret_code == WAIT_OBJECT_0 + 1) { | ||
| 7171 | if (ret_code == WAIT_OBJECT_0) | ||
| 7172 | LogErr(SYSTEM_LEVEL, ER_NORMAL_SERVER_SHUTDOWN, my_progname); | ||
| 7173 | else | ||
| 7174 | signal_hand_thr_exit_code = MYSQLD_RESTART_EXIT; | ||
| 7175 | |||
| 7176 | set_connection_events_loop_aborted(true); | ||
| 7177 | close_connections(); | ||
| 7178 | my_thread_end(); | ||
| 7179 | my_thread_exit(0); | ||
| 7180 | } | ||
| 7181 | return 0; | ||
| 7182 | } | ||
| 7183 | |||
| 7184 | static void create_shutdown_and_restart_thread() { | ||
| 7185 | DBUG_TRACE; | ||
| 7186 | |||
| 7187 | const char *errmsg; | ||
| 7188 | my_thread_attr_t thr_attr; | ||
| 7189 | SECURITY_ATTRIBUTES *shutdown_sec_attr; | ||
| 7190 | |||
| 7191 | my_security_attr_create(&shutdown_sec_attr, &errmsg, GENERIC_ALL, | ||
| 7192 | SYNCHRONIZE | EVENT_MODIFY_STATE); | ||
| 7193 | |||
| 7194 | if (!opt_no_monitor) { | ||
| 7195 | snprintf(shutdown_event_name, sizeof(shutdown_event_name), | ||
| 7196 | "mysqld%s_shutdown", get_monitor_pid()); | ||
| 7197 | } | ||
| 7198 | |||
| 7199 | hEventShutdown = | ||
| 7200 | CreateEvent(shutdown_sec_attr, FALSE, FALSE, shutdown_event_name); | ||
| 7201 | hEventRestart = CreateEvent(0, FALSE, FALSE, restart_event_name); | ||
| 7202 | |||
| 7203 | my_thread_attr_init(&thr_attr); | ||
| 7204 | |||
| 7205 | if (my_thread_create(&shutdown_restart_thr_handle, &thr_attr, | ||
| 7206 | handle_shutdown_and_restart, 0)) | ||
| 7207 | LogErr(WARNING_LEVEL, ER_CANT_CREATE_SHUTDOWN_THREAD, errno); | ||
| 7208 | |||
| 7209 | my_security_attr_free(shutdown_sec_attr); | ||
| 7210 | my_thread_attr_destroy(&thr_attr); | ||
| 7211 | 12069 | } | |
| 7212 |
1/2✓ Branch 0 taken 12069 times.
✗ Branch 1 not taken.
|
12069 | #endif /* _WIN32 */ |
| 7213 |
2/2✓ Branch 0 taken 1339659 times.
✓ Branch 1 taken 12069 times.
|
1351728 | |
| 7214 | 1339659 | #ifndef NDEBUG | |
| 7215 | 1339659 | /* | |
| 7216 |
2/2✓ Branch 0 taken 16075908 times.
✓ Branch 1 taken 1339659 times.
|
17415567 | Debugging helper function to keep the locale database |
| 7217 | (see sql_locale.cc) and max_month_name_length and | ||
| 7218 | 32151816 | max_day_name_length variable values in consistent state. | |
| 7219 | 16075908 | */ | |
| 7220 |
1/2✓ Branch 0 taken 16075908 times.
✗ Branch 1 not taken.
|
16075908 | static void test_lc_time_sz() { |
| 7221 | DBUG_TRACE; | ||
| 7222 |
2/2✓ Branch 0 taken 9377613 times.
✓ Branch 1 taken 1339659 times.
|
10717272 | for (MY_LOCALE **loc = my_locales; *loc; loc++) { |
| 7223 | 9377613 | size_t max_month_len = 0; | |
| 7224 | 9377613 | size_t max_day_len = 0; | |
| 7225 |
1/2✓ Branch 0 taken 9377613 times.
✗ Branch 1 not taken.
|
9377613 | for (const char **month = (*loc)->month_names->type_names; *month; |
| 7226 | month++) { | ||
| 7227 |
1/2✓ Branch 0 taken 1339659 times.
✗ Branch 1 not taken.
|
1339659 | max_month_len = std::max( |
| 7228 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1339659 times.
|
1339659 | max_month_len, my_numchars_mb(&my_charset_utf8_general_ci, *month, |
| 7229 | ✗ | *month + strlen(*month))); | |
| 7230 | } | ||
| 7231 | ✗ | for (const char **day = (*loc)->day_names->type_names; *day; day++) { | |
| 7232 | max_day_len = | ||
| 7233 | std::max(max_day_len, my_numchars_mb(&my_charset_utf8_general_ci, | ||
| 7234 | 12069 | *day, *day + strlen(*day))); | |
| 7235 | } | ||
| 7236 | if ((*loc)->max_month_name_length != max_month_len || | ||
| 7237 | (*loc)->max_day_name_length != max_day_len) { | ||
| 7238 | DBUG_PRINT("Wrong max day name(or month name) length for locale:", | ||
| 7239 | ("%s", (*loc)->name)); | ||
| 7240 | assert(0); | ||
| 7241 | } | ||
| 7242 | 11401 | } | |
| 7243 | 11401 | } | |
| 7244 | 11401 | #endif // NDEBUG | |
| 7245 | |||
| 7246 | 12121 | /* | |
| 7247 | @brief : Set opt_super_readonly to user supplied value before | ||
| 7248 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | enabling communication channels to accept user connections |
| 7249 | */ | ||
| 7250 | |||
| 7251 | static void set_super_read_only_post_init() { | ||
| 7252 | opt_super_readonly = super_read_only; | ||
| 7253 | } | ||
| 7254 | |||
| 7255 | static void calculate_mysql_home_from_my_progname() { | ||
| 7256 | const std::string runtime_output_directory_addon{ | ||
| 7257 | "/runtime_output_directory/"}; | ||
| 7258 | #if defined(_WIN32) || defined(APPLE_XCODE) | ||
| 7259 | /* Allow Win32 users to move MySQL anywhere */ | ||
| 7260 | char prg_dev[FN_REFLEN]; | ||
| 7261 | my_path(prg_dev, my_progname, nullptr); | ||
| 7262 | |||
| 7263 | // On windows or Xcode the basedir will always be one level up from where | ||
| 7264 | // the executable is located. E.g. <basedir>/bin/mysqld.exe in a | ||
| 7265 | // package, or <basedir>/runtime_output_directory/<buildconfig>/mysqld.exe | ||
| 7266 | // for a sandbox build. | ||
| 7267 | strcat(prg_dev, "/../"); // Remove containing directory to get base dir | ||
| 7268 | cleanup_dirname(mysql_home, prg_dev); | ||
| 7269 | |||
| 7270 | // New layout: <cmake_binary_dir>/runtime_output_directory/<buildconfig>/ | ||
| 7271 | char cmake_binary_dir[FN_REFLEN]; | ||
| 7272 | size_t dlen = 0; | ||
| 7273 | dirname_part(cmake_binary_dir, mysql_home, &dlen); | ||
| 7274 | if (dlen > runtime_output_directory_addon.length() && | ||
| 7275 | (!strcmp( | ||
| 7276 | cmake_binary_dir + (dlen - runtime_output_directory_addon.length()), | ||
| 7277 | runtime_output_directory_addon.c_str()) || | ||
| 7278 | !strcmp( | ||
| 7279 | cmake_binary_dir + (dlen - runtime_output_directory_addon.length()), | ||
| 7280 | 12121 | "\\runtime_output_directory\\"))) { | |
| 7281 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12121 times.
|
12121 | mysql_home[strlen(mysql_home) - 1] = '\0'; // remove trailing |
| 7282 | ✗ | dirname_part(cmake_binary_dir, mysql_home, &dlen); | |
| 7283 | strmake(mysql_home, cmake_binary_dir, sizeof(mysql_home) - 1); | ||
| 7284 | } | ||
| 7285 | 12121 | // The sql_print_information below outputs nothing ?? | |
| 7286 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | // fprintf(stderr, "mysql_home %s\n", mysql_home); |
| 7287 |
3/4✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12120 times.
✓ Branch 3 taken 1 times.
|
24242 | // fflush(stderr); |
| 7288 |
2/2✓ Branch 0 taken 12120 times.
✓ Branch 1 taken 1 times.
|
12121 | #else |
| 7289 | const char *tmpenv = getenv("MY_BASEDIR_VERSION"); | ||
| 7290 | if (tmpenv != nullptr) { | ||
| 7291 | 12120 | strmake(mysql_home, tmpenv, sizeof(mysql_home) - 1); | |
| 7292 |
1/2✓ Branch 0 taken 12120 times.
✗ Branch 1 not taken.
|
12120 | } else { |
| 7293 |
1/2✓ Branch 0 taken 12120 times.
✗ Branch 1 not taken.
|
12120 | char progdir[FN_REFLEN]; |
| 7294 | size_t dlen = 0; | ||
| 7295 | 1 | dirname_part(progdir, my_progname, &dlen); | |
| 7296 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (dlen > runtime_output_directory_addon.length() && |
| 7297 | !strcmp(progdir + (dlen - runtime_output_directory_addon.length()), | ||
| 7298 | runtime_output_directory_addon.c_str())) { | ||
| 7299 | char cmake_binary_dir[FN_REFLEN]; | ||
| 7300 | 12121 | progdir[strlen(progdir) - 1] = '\0'; // remove trailing "/" | |
| 7301 | 12121 | dirname_part(cmake_binary_dir, progdir, &dlen); | |
| 7302 | strmake(mysql_home, cmake_binary_dir, sizeof(mysql_home) - 1); | ||
| 7303 | } else { | ||
| 7304 | strcat(progdir, "/../"); | ||
| 7305 | cleanup_dirname(mysql_home, progdir); | ||
| 7306 | } | ||
| 7307 | } | ||
| 7308 | #endif | ||
| 7309 | mysql_home_ptr = mysql_home; | ||
| 7310 | } | ||
| 7311 | |||
| 7312 | /** | ||
| 7313 | 12109 | Helper class for loading keyring component | |
| 7314 | 12109 | Keyring component is loaded after minimal chassis initialization. | |
| 7315 | 12109 | At this time, home dir and plugin dir may not be initialized. | |
| 7316 | 12109 | ||
| 7317 | 12109 | This helper class sets them temporarily by reading configurations | |
| 7318 | 12109 | and resets them in destructor. | |
| 7319 | 12109 | */ | |
| 7320 | 12109 | class Plugin_and_data_dir_option_parser final { | |
| 7321 | 12109 | public: | |
| 7322 | 12109 | Plugin_and_data_dir_option_parser(int argc, char **argv) | |
| 7323 | : datadir_(nullptr), | ||
| 7324 | 12109 | plugindir_(nullptr), | |
| 7325 | save_homedir_{0}, | ||
| 7326 | save_plugindir_{0}, | ||
| 7327 | valid_(false) { | ||
| 7328 | char *ptr, **res, *datadir = nullptr, *plugindir = nullptr; | ||
| 7329 | char dir[FN_REFLEN] = {0}, local_datadir_buffer[FN_REFLEN] = {0}, | ||
| 7330 | 12109 | local_plugindir_buffer[FN_REFLEN] = {0}; | |
| 7331 | const char *dirs = nullptr; | ||
| 7332 | |||
| 7333 | my_option datadir_options[] = { | ||
| 7334 | {"datadir", 0, "", &datadir, nullptr, nullptr, GET_STR, OPT_ARG, 0, 0, | ||
| 7335 | 0, nullptr, 0, nullptr}, | ||
| 7336 | {"plugin_dir", 0, "", &plugindir, nullptr, nullptr, GET_STR, OPT_ARG, 0, | ||
| 7337 | 12109 | 0, 0, nullptr, 0, nullptr}, | |
| 7338 | 12109 | {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, | |
| 7339 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | 0, 0, nullptr, 0, nullptr}}; |
| 7340 | ✗ | ||
| 7341 | 12109 | /* | |
| 7342 | 12109 | create temporary args list and pass it to handle_options. | |
| 7343 | 12109 | We do this because we don't want to mess with the actual | |
| 7344 | argument list. handle_options() trims the processed parts. | ||
| 7345 | 12109 | */ | |
| 7346 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | MEM_ROOT alloc{PSI_NOT_INSTRUMENTED, 512}; |
| 7347 | if (!(ptr = | ||
| 7348 | ✗ | (char *)alloc.Alloc(sizeof(alloc) + (argc + 1) * sizeof(char *)))) | |
| 7349 | ✗ | return; | |
| 7350 | memset(ptr, 0, (sizeof(char *) * (argc + 1))); | ||
| 7351 | 12109 | res = (char **)(ptr); | |
| 7352 | memcpy((uchar *)res, (char *)(argv), (argc) * sizeof(char *)); | ||
| 7353 |
2/2✓ Branch 0 taken 27 times.
✓ Branch 1 taken 12082 times.
|
12109 | |
| 7354 | my_getopt_skip_unknown = true; | ||
| 7355 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 27 times.
|
27 | if (my_handle_options(&argc, &res, datadir_options, nullptr, nullptr, |
| 7356 | true)) { | ||
| 7357 | my_getopt_skip_unknown = false; | ||
| 7358 | return; | ||
| 7359 | } | ||
| 7360 |
2/4✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
|
27 | my_getopt_skip_unknown = false; |
| 7361 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | |
| 7362 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | if (!datadir) { |
| 7363 | /* mysql_real_data_home must be initialized at this point */ | ||
| 7364 | 27 | assert(mysql_real_data_home[0]); | |
| 7365 | /* | ||
| 7366 | 12109 | mysql_home_ptr should also be initialized at this point. | |
| 7367 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | See calculate_mysql_home_from_my_progname() for details |
| 7368 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | */ |
| 7369 | 12109 | assert(mysql_home_ptr && mysql_home_ptr[0]); | |
| 7370 | convert_dirname(local_datadir_buffer, mysql_real_data_home, NullS); | ||
| 7371 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | (void)my_load_path(local_datadir_buffer, local_datadir_buffer, |
| 7372 |
3/4✓ Branch 0 taken 6067 times.
✓ Branch 1 taken 6042 times.
✓ Branch 2 taken 6067 times.
✗ Branch 3 not taken.
|
12109 | mysql_home_ptr); |
| 7373 | datadir = local_datadir_buffer; | ||
| 7374 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | } |
| 7375 | dirs = datadir; | ||
| 7376 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | unpack_dirname(dir, dirs); |
| 7377 | datadir_ = my_strdup(PSI_INSTRUMENT_ME, dir, MYF(0)); | ||
| 7378 | memset(dir, 0, FN_REFLEN); | ||
| 7379 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 7380 | 12109 | convert_dirname(local_plugindir_buffer, | |
| 7381 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | plugindir ? plugindir : get_relative_path(PLUGINDIR), |
| 7382 | 12109 | NullS); | |
| 7383 | (void)my_load_path(local_plugindir_buffer, local_plugindir_buffer, | ||
| 7384 | mysql_home); | ||
| 7385 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | plugindir_ = my_strdup(PSI_INSTRUMENT_ME, local_plugindir_buffer, MYF(0)); |
| 7386 | ✗ | ||
| 7387 | ✗ | /* Backup mysql_real_data_home */ | |
| 7388 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | if (mysql_real_data_home[0]) |
| 7389 | 12109 | memcpy(save_homedir_, mysql_real_data_home, strlen(mysql_real_data_home)); | |
| 7390 | if (datadir_ != nullptr) | ||
| 7391 | 12109 | memcpy(mysql_real_data_home, datadir_, strlen(datadir_)); | |
| 7392 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 7393 | /* Backup opt_plugin_dir */ | ||
| 7394 | 12109 | if (opt_plugin_dir[0]) | |
| 7395 | 12109 | memcpy(save_plugindir_, opt_plugin_dir, | |
| 7396 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | std::min(static_cast<size_t>(FN_REFLEN), strlen(opt_plugin_dir))); |
| 7397 | 12109 | if (plugindir_ != nullptr) | |
| 7398 | 12109 | memcpy(opt_plugin_dir, plugindir_, strlen(plugindir_)); | |
| 7399 | 12109 | ||
| 7400 | valid_ = true; | ||
| 7401 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | } |
| 7402 | 12109 | ||
| 7403 | 12109 | ~Plugin_and_data_dir_option_parser() { | |
| 7404 | 12109 | valid_ = false; | |
| 7405 | if (datadir_ != nullptr) { | ||
| 7406 | 12109 | memset(mysql_real_data_home, 0, sizeof(mysql_real_data_home)); | |
| 7407 | memcpy(mysql_real_data_home, save_homedir_, strlen(save_homedir_)); | ||
| 7408 | 12109 | my_free(datadir_); | |
| 7409 | } | ||
| 7410 | if (plugindir_ != nullptr) { | ||
| 7411 | memset(opt_plugin_dir, 0, sizeof(opt_plugin_dir)); | ||
| 7412 | memcpy(opt_plugin_dir, save_plugindir_, strlen(save_plugindir_)); | ||
| 7413 | my_free(plugindir_); | ||
| 7414 | } | ||
| 7415 | } | ||
| 7416 | |||
| 7417 | bool valid() const { return valid_; } | ||
| 7418 | |||
| 7419 | private: | ||
| 7420 | char *datadir_; | ||
| 7421 | 12121 | char *plugindir_; | |
| 7422 | char save_homedir_[FN_REFLEN + 1]; | ||
| 7423 | char save_plugindir_[FN_REFLEN + 1]; | ||
| 7424 | bool valid_; | ||
| 7425 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | }; |
| 7426 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | |
| 7427 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | #ifdef _WIN32 |
| 7428 | int win_main(int argc, char **argv) | ||
| 7429 | #else | ||
| 7430 | int mysqld_main(int argc, char **argv) | ||
| 7431 | #endif | ||
| 7432 | { | ||
| 7433 | 12121 | // Substitute the full path to the executable in argv[0] | |
| 7434 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | substitute_progpath(argv); |
| 7435 | sysd::notify_connect(); | ||
| 7436 | sysd::notify("STATUS=Server startup in progress\n"); | ||
| 7437 | |||
| 7438 |
1/2✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
|
12121 | /* |
| 7439 | Perform basic thread library and malloc initialization, | ||
| 7440 | to be able to read defaults files and parse options. | ||
| 7441 |
2/4✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12121 times.
|
12121 | */ |
| 7442 | my_progname = argv[0]; | ||
| 7443 | ✗ | calculate_mysql_home_from_my_progname(); | |
| 7444 | ✗ | ||
| 7445 | ✗ | #ifndef _WIN32 | |
| 7446 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 7447 | pre_initialize_performance_schema(); | ||
| 7448 | #endif /*WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 7449 | 12121 | // For windows, my_init() is called from the win specific mysqld_main | |
| 7450 | 12121 | if (my_init()) // init my_sys library & pthreads | |
| 7451 | 12121 | { | |
| 7452 | 12121 | LogErr(ERROR_LEVEL, ER_MYINIT_FAILED); | |
| 7453 |
3/4✓ Branch 0 taken 12121 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12115 times.
|
12121 | flush_error_log_messages(); |
| 7454 | return 1; | ||
| 7455 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | } |
| 7456 | 6 | #endif /* _WIN32 */ | |
| 7457 | |||
| 7458 | orig_argc = argc; | ||
| 7459 | orig_argv = argv; | ||
| 7460 |
2/4✓ Branch 0 taken 12115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12115 times.
✗ Branch 3 not taken.
|
12115 | my_getopt_use_args_separator = true; |
| 7461 | my_defaults_read_login_file = false; | ||
| 7462 | if (load_defaults(MYSQL_CONFIG_NAME, load_default_groups, &argc, &argv, | ||
| 7463 | &argv_alloc)) { | ||
| 7464 | 12115 | flush_error_log_messages(); | |
| 7465 | return 1; | ||
| 7466 | } | ||
| 7467 | 12115 | ||
| 7468 | /* Set data dir directory paths */ | ||
| 7469 |
1/2✓ Branch 0 taken 12115 times.
✗ Branch 1 not taken.
|
12115 | strmake(mysql_real_data_home, get_relative_path(MYSQL_DATADIR), |
| 7470 | sizeof(mysql_real_data_home) - 1); | ||
| 7471 | |||
| 7472 | /* Must be initialized early for comparison of options name */ | ||
| 7473 | system_charset_info = &my_charset_utf8_general_ci; | ||
| 7474 | |||
| 7475 | /* Write mysys error messages to the error log. */ | ||
| 7476 | local_message_hook = error_log_print; | ||
| 7477 | |||
| 7478 | sys_var_init(); | ||
| 7479 | |||
| 7480 | #ifdef _WIN32 | ||
| 7481 | if (mysys::is_my_malloc_using_jemalloc()) { | ||
| 7482 | LogErr(INFORMATION_LEVEL, ER_MY_MALLOC_USING_JEMALLOC); | ||
| 7483 | } else { | ||
| 7484 | for (auto &msg : mysys::fetch_jemalloc_initialization_messages()) { | ||
| 7485 | LogErr(msg.m_severity, ER_MY_MALLOC_USING_JEMALLOC + msg.m_ecode, | ||
| 7486 | 12115 | msg.m_message.c_str()); | |
| 7487 |
1/2✓ Branch 0 taken 12115 times.
✗ Branch 1 not taken.
|
12115 | } |
| 7488 |
6/8✓ Branch 0 taken 12115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12115 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12109 times.
✓ Branch 5 taken 6 times.
✓ Branch 6 taken 6 times.
✓ Branch 7 taken 12109 times.
|
24224 | } |
| 7489 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | #endif |
| 7490 | /* | ||
| 7491 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | Initialize variables cache for persisted variables, load persisted |
| 7492 | 6 | config file and append parse early read only persisted variables | |
| 7493 | to command line options if present. | ||
| 7494 | */ | ||
| 7495 | 12109 | bool arg_separator_added = false; | |
| 7496 | 12109 | if (persisted_variables_cache.init(&argc, &argv) || | |
| 7497 | persisted_variables_cache.load_persist_file() || | ||
| 7498 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | persisted_variables_cache.append_parse_early_variables( |
| 7499 | &argc, &argv, arg_separator_added)) { | ||
| 7500 | flush_error_log_messages(); | ||
| 7501 | return 1; | ||
| 7502 | } | ||
| 7503 | |||
| 7504 | remaining_argc = argc; | ||
| 7505 | remaining_argv = argv; | ||
| 7506 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 7507 | init_variable_default_paths(); | ||
| 7508 | |||
| 7509 | int heo_error; | ||
| 7510 | |||
| 7511 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 7512 |
2/6✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12109 | /* |
| 7513 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | Initialize the array of performance schema instrument configurations. |
| 7514 | */ | ||
| 7515 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | init_pfs_instrument_array(); |
| 7516 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ |
| 7517 | |||
| 7518 | 12109 | /* init_error_log() is required by error_log_printf() in | |
| 7519 | 12109 | option_error_reporter() */ | |
| 7520 |
3/4✓ Branch 0 taken 12104 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 12104 times.
✗ Branch 3 not taken.
|
12109 | // Init error log subsystem. This does not actually open the log yet. |
| 7521 | if (init_error_log()) unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7522 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | heo_error = handle_early_options(); |
| 7523 | |||
| 7524 | opt_jemalloc_detected = jemalloc_detected(); | ||
| 7525 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | jemalloc_profiling_enable(opt_jemalloc_profiling_enabled); |
| 7526 |
6/6✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 11790 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 11790 times.
✓ Branch 5 taken 319 times.
|
12109 | |
| 7527 | init_sql_statement_names(); | ||
| 7528 | ulong requested_open_files = 0; | ||
| 7529 | 11790 | if (!opt_validate_config) adjust_related_options(&requested_open_files); | |
| 7530 | 11790 | // moved signal initialization here so that PFS thread inherited signal mask | |
| 7531 | 11790 | my_init_signals(); | |
| 7532 | 11790 | ||
| 7533 | 11790 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | |
| 7534 | if (heo_error == 0) { | ||
| 7535 |
1/2✓ Branch 0 taken 11790 times.
✗ Branch 1 not taken.
|
11790 | if (!is_help_or_validate_option() && !opt_initialize) { |
| 7536 | int pfs_rc; | ||
| 7537 | /* Add sizing hints from the server sizing parameters. */ | ||
| 7538 | pfs_param.m_hints.m_table_definition_cache = table_def_size; | ||
| 7539 | pfs_param.m_hints.m_table_open_cache = table_cache_size; | ||
| 7540 | pfs_param.m_hints.m_max_connections = max_connections; | ||
| 7541 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11790 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11790 | pfs_param.m_hints.m_open_files_limit = requested_open_files; |
| 7542 | ✗ | pfs_param.m_hints.m_max_prepared_stmt_count = max_prepared_stmt_count; | |
| 7543 | ✗ | ||
| 7544 | pfs_rc = initialize_performance_schema( | ||
| 7545 | &pfs_param, &psi_thread_hook, &psi_mutex_hook, &psi_rwlock_hook, | ||
| 7546 | &psi_cond_hook, &psi_file_hook, &psi_socket_hook, &psi_table_hook, | ||
| 7547 | &psi_mdl_hook, &psi_idle_hook, &psi_stage_hook, &psi_statement_hook, | ||
| 7548 | &psi_transaction_hook, &psi_memory_hook, &psi_error_hook, | ||
| 7549 | &psi_data_lock_hook, &psi_system_hook, &psi_tls_channel_hook); | ||
| 7550 | if ((pfs_rc != 0) && pfs_param.m_enabled) { | ||
| 7551 | pfs_param.m_enabled = false; | ||
| 7552 | LogErr(WARNING_LEVEL, ER_PERFSCHEMA_INIT_FAILED); | ||
| 7553 | } | ||
| 7554 | } | ||
| 7555 | } | ||
| 7556 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 7557 | |||
| 7558 | #ifdef WITH_LOCK_ORDER | ||
| 7559 | if (heo_error == 0) { | ||
| 7560 | if (lo_param.m_enabled && !opt_help && !opt_initialize) { | ||
| 7561 | int lo_rc; | ||
| 7562 | lo_rc = LO_init(&lo_param, &psi_thread_hook, &psi_mutex_hook, | ||
| 7563 | &psi_rwlock_hook, &psi_cond_hook, &psi_file_hook, | ||
| 7564 | &psi_socket_hook, &psi_table_hook, &psi_mdl_hook, | ||
| 7565 | &psi_idle_hook, &psi_stage_hook, &psi_statement_hook, | ||
| 7566 | &psi_transaction_hook, &psi_memory_hook); | ||
| 7567 | if (lo_rc != 0) { | ||
| 7568 | LogErr(WARNING_LEVEL, ER_LOCK_ORDER_INIT_FAILED); | ||
| 7569 | } | ||
| 7570 | } | ||
| 7571 | } | ||
| 7572 | #endif /* WITH_LOCK_ORDER */ | ||
| 7573 | |||
| 7574 | /* | ||
| 7575 | Other provider of the instrumentation interface should | ||
| 7576 | initialize PSI_hook here: | ||
| 7577 | - HAVE_PSI_INTERFACE is for the instrumentation interface | ||
| 7578 | - WITH_PERFSCHEMA_STORAGE_ENGINE is for one implementation | ||
| 7579 | of the interface, | ||
| 7580 | but there could be alternate implementations, which is why | ||
| 7581 | these two defines are kept separate. | ||
| 7582 | */ | ||
| 7583 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | |
| 7584 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | #ifdef HAVE_PSI_INTERFACE |
| 7585 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | /* |
| 7586 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | Obtain the current performance schema instrumentation interface, |
| 7587 | if available. | ||
| 7588 | */ | ||
| 7589 | |||
| 7590 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | void *service; |
| 7591 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7592 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_thread_hook != nullptr) { |
| 7593 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_thread_hook->get_interface(PSI_CURRENT_THREAD_VERSION); |
| 7594 | if (service != nullptr) { | ||
| 7595 | set_psi_thread_service(service); | ||
| 7596 | } | ||
| 7597 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7598 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7599 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_mutex_hook != nullptr) { |
| 7600 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_mutex_hook->get_interface(PSI_CURRENT_MUTEX_VERSION); |
| 7601 | if (service != nullptr) { | ||
| 7602 | set_psi_mutex_service(service); | ||
| 7603 | } | ||
| 7604 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7605 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7606 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_rwlock_hook != nullptr) { |
| 7607 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_rwlock_hook->get_interface(PSI_CURRENT_RWLOCK_VERSION); |
| 7608 | if (service != nullptr) { | ||
| 7609 | set_psi_rwlock_service(service); | ||
| 7610 | } | ||
| 7611 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7612 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7613 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_cond_hook != nullptr) { |
| 7614 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_cond_hook->get_interface(PSI_CURRENT_COND_VERSION); |
| 7615 | if (service != nullptr) { | ||
| 7616 | set_psi_cond_service(service); | ||
| 7617 | } | ||
| 7618 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7619 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7620 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_file_hook != nullptr) { |
| 7621 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_file_hook->get_interface(PSI_CURRENT_FILE_VERSION); |
| 7622 | if (service != nullptr) { | ||
| 7623 | set_psi_file_service(service); | ||
| 7624 | } | ||
| 7625 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7626 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7627 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_socket_hook != nullptr) { |
| 7628 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_socket_hook->get_interface(PSI_CURRENT_SOCKET_VERSION); |
| 7629 | if (service != nullptr) { | ||
| 7630 | set_psi_socket_service(service); | ||
| 7631 | } | ||
| 7632 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7633 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7634 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_table_hook != nullptr) { |
| 7635 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_table_hook->get_interface(PSI_CURRENT_TABLE_VERSION); |
| 7636 | if (service != nullptr) { | ||
| 7637 | set_psi_table_service(service); | ||
| 7638 | } | ||
| 7639 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7640 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7641 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_mdl_hook != nullptr) { |
| 7642 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_mdl_hook->get_interface(PSI_CURRENT_MDL_VERSION); |
| 7643 | if (service != nullptr) { | ||
| 7644 | set_psi_mdl_service(service); | ||
| 7645 | } | ||
| 7646 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7647 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7648 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_idle_hook != nullptr) { |
| 7649 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_idle_hook->get_interface(PSI_CURRENT_IDLE_VERSION); |
| 7650 | if (service != nullptr) { | ||
| 7651 | set_psi_idle_service(service); | ||
| 7652 | } | ||
| 7653 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7654 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7655 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_stage_hook != nullptr) { |
| 7656 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_stage_hook->get_interface(PSI_CURRENT_STAGE_VERSION); |
| 7657 | if (service != nullptr) { | ||
| 7658 | set_psi_stage_service(service); | ||
| 7659 | } | ||
| 7660 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7661 | |||
| 7662 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_statement_hook != nullptr) { |
| 7663 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_statement_hook->get_interface(PSI_CURRENT_STATEMENT_VERSION); |
| 7664 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (service != nullptr) { |
| 7665 | set_psi_statement_service(service); | ||
| 7666 | } | ||
| 7667 | } | ||
| 7668 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | |
| 7669 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_transaction_hook != nullptr) { |
| 7670 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = |
| 7671 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | psi_transaction_hook->get_interface(PSI_CURRENT_TRANSACTION_VERSION); |
| 7672 | if (service != nullptr) { | ||
| 7673 | set_psi_transaction_service(service); | ||
| 7674 | } | ||
| 7675 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7676 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7677 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_memory_hook != nullptr) { |
| 7678 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_memory_hook->get_interface(PSI_CURRENT_MEMORY_VERSION); |
| 7679 | if (service != nullptr) { | ||
| 7680 | set_psi_memory_service(service); | ||
| 7681 | } | ||
| 7682 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7683 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7684 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_error_hook != nullptr) { |
| 7685 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_error_hook->get_interface(PSI_CURRENT_ERROR_VERSION); |
| 7686 | if (service != nullptr) { | ||
| 7687 | set_psi_error_service(service); | ||
| 7688 | } | ||
| 7689 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7690 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | |
| 7691 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_data_lock_hook != nullptr) { |
| 7692 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_data_lock_hook->get_interface(PSI_CURRENT_DATA_LOCK_VERSION); |
| 7693 | if (service != nullptr) { | ||
| 7694 | set_psi_data_lock_service(service); | ||
| 7695 | } | ||
| 7696 |
2/2✓ Branch 0 taken 11783 times.
✓ Branch 1 taken 326 times.
|
12109 | } |
| 7697 | |||
| 7698 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (psi_system_hook != nullptr) { |
| 7699 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | service = psi_system_hook->get_interface(PSI_CURRENT_SYSTEM_VERSION); |
| 7700 |
1/2✓ Branch 0 taken 11783 times.
✗ Branch 1 not taken.
|
11783 | if (service != nullptr) { |
| 7701 | set_psi_system_service(service); | ||
| 7702 | } | ||
| 7703 | } | ||
| 7704 | |||
| 7705 | if (psi_tls_channel_hook != nullptr) { | ||
| 7706 | service = | ||
| 7707 | psi_tls_channel_hook->get_interface(PSI_CURRENT_TLS_CHANNEL_VERSION); | ||
| 7708 | if (service != nullptr) { | ||
| 7709 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | set_psi_tls_channel_service(service); |
| 7710 | } | ||
| 7711 | } | ||
| 7712 | |||
| 7713 | /* | ||
| 7714 | Now that we have parsed the command line arguments, and have initialized | ||
| 7715 | the performance schema itself, the next step is to register all the | ||
| 7716 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | server instruments. |
| 7717 | */ | ||
| 7718 | init_server_psi_keys(); | ||
| 7719 | |||
| 7720 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | /* |
| 7721 | Now that some instrumentation is in place, | ||
| 7722 | recreate objects which were initialised early, | ||
| 7723 | 12109 | so that they are instrumented as well. | |
| 7724 | */ | ||
| 7725 | my_thread_global_reinit(); | ||
| 7726 | #endif /* HAVE_PSI_INTERFACE */ | ||
| 7727 | |||
| 7728 | /* This limits ability to configure SSL library through config options */ | ||
| 7729 | init_ssl(); | ||
| 7730 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | |
| 7731 | ✗ | /* Set umask as early as possible */ | |
| 7732 | ✗ | umask(((~my_umask) & 0666)); | |
| 7733 | |||
| 7734 | /* | ||
| 7735 | Initialize Components core subsystem early on, once we have PSI, which it | ||
| 7736 | uses. This part doesn't use any more MySQL-specific functionalities but | ||
| 7737 | 12109 | error logging and PFS. | |
| 7738 | */ | ||
| 7739 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | if (component_infrastructure_init()) { |
| 7740 | flush_error_log_messages(); | ||
| 7741 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | return 1; |
| 7742 | ✗ | } | |
| 7743 | ✗ | ||
| 7744 | { | ||
| 7745 | /* Must be initialized early because it is required by dynamic loader */ | ||
| 7746 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | files_charset_info = &my_charset_utf8_general_ci; |
| 7747 | ✗ | auto keyring_helper = std::make_unique<Plugin_and_data_dir_option_parser>( | |
| 7748 | ✗ | remaining_argc, remaining_argv); | |
| 7749 | |||
| 7750 | if (keyring_helper->valid() == false) { | ||
| 7751 | flush_error_log_messages(); | ||
| 7752 | return 1; | ||
| 7753 | } | ||
| 7754 | |||
| 7755 | if (initialize_manifest_file_components()) { | ||
| 7756 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | flush_error_log_messages(); |
| 7757 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | return 1; |
| 7758 | } | ||
| 7759 | |||
| 7760 | /* | ||
| 7761 | If keyring component was loaded through manifest file, services provided | ||
| 7762 | by such a component should get priority over keyring plugin. That's why | ||
| 7763 | we have to set defaults before proxy keyring services are loaded. | ||
| 7764 |
2/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12109 times.
|
12109 | */ |
| 7765 | set_srv_keyring_implementation_as_default(); | ||
| 7766 | ✗ | } | |
| 7767 | ✗ | ||
| 7768 | /* | ||
| 7769 | 12109 | Append read only persisted variables to command line now. | |
| 7770 | Note that if arg separator is already added, it will not | ||
| 7771 | be added again. | ||
| 7772 | */ | ||
| 7773 | if (persisted_variables_cache.append_read_only_variables( | ||
| 7774 | &remaining_argc, &remaining_argv, arg_separator_added, false)) { | ||
| 7775 |
6/6✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 11790 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 11790 times.
✓ Branch 5 taken 319 times.
|
12109 | flush_error_log_messages(); |
| 7776 |
1/2✓ Branch 0 taken 11790 times.
✗ Branch 1 not taken.
|
11790 | return 1; |
| 7777 |
1/2✓ Branch 0 taken 11790 times.
✗ Branch 1 not taken.
|
11790 | } |
| 7778 | my_getopt_use_args_separator = false; | ||
| 7779 | |||
| 7780 | /* | ||
| 7781 | Initialize Performance Schema component services. | ||
| 7782 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | */ |
| 7783 |
6/6✓ Branch 0 taken 12090 times.
✓ Branch 1 taken 19 times.
✓ Branch 2 taken 11790 times.
✓ Branch 3 taken 300 times.
✓ Branch 4 taken 11790 times.
✓ Branch 5 taken 319 times.
|
12109 | #ifdef HAVE_PSI_THREAD_INTERFACE |
| 7784 |
2/4✓ Branch 0 taken 11790 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11790 times.
|
11790 | if (!is_help_or_validate_option() && !opt_initialize) { |
| 7785 | ✗ | register_pfs_notification_service(); | |
| 7786 | ✗ | register_pfs_resource_group_service(); | |
| 7787 | } | ||
| 7788 | #endif | ||
| 7789 | |||
| 7790 | // Initialize the resource group subsystem. | ||
| 7791 | auto res_grp_mgr = resourcegroups::Resource_group_mgr::instance(); | ||
| 7792 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | if (!is_help_or_validate_option() && !opt_initialize) { |
| 7793 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | if (res_grp_mgr->init()) { |
| 7794 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | LogErr(ERROR_LEVEL, ER_RESOURCE_GROUP_SUBSYSTEM_INIT_FAILED); |
| 7795 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7796 | } | ||
| 7797 | } | ||
| 7798 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 7799 | #ifdef HAVE_PSI_THREAD_INTERFACE | ||
| 7800 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | /* Instrument the main thread */ |
| 7801 | PSI_thread *psi = PSI_THREAD_CALL(new_thread)(key_thread_main, 0, nullptr, 0); | ||
| 7802 | PSI_THREAD_CALL(set_thread_os_id)(psi); | ||
| 7803 | PSI_THREAD_CALL(set_thread)(psi); | ||
| 7804 | #endif /* HAVE_PSI_THREAD_INTERFACE */ | ||
| 7805 | |||
| 7806 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | /* Initialize audit interface globals. Audit plugins are inited later. */ |
| 7807 | mysql_audit_initialize(); | ||
| 7808 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | |
| 7809 | Srv_session::module_init(); | ||
| 7810 | |||
| 7811 | /* | ||
| 7812 | Perform basic query log initialization. Should be called after | ||
| 7813 | MY_INIT, as it initializes mutexes. | ||
| 7814 | */ | ||
| 7815 | query_logger.init(); | ||
| 7816 | |||
| 7817 | if (heo_error) { | ||
| 7818 | ✗ | /* | |
| 7819 | Parsing command line option failed, | ||
| 7820 | Since we don't have a workable remaining_argc/remaining_argv | ||
| 7821 | to continue the server initialization, this is as far as this | ||
| 7822 | code can go. | ||
| 7823 | ✗ | This is the best effort to log meaningful messages: | |
| 7824 | - messages will be printed to stderr, which is not redirected yet, | ||
| 7825 | - messages will be printed in the NT event log, for windows. | ||
| 7826 |
3/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 12069 times.
|
12109 | */ |
| 7827 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | flush_error_log_messages(); |
| 7828 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
40 | /* |
| 7829 | Not enough initializations for unireg_abort() | ||
| 7830 | Using exit() for windows. | ||
| 7831 |
1/2✓ Branch 0 taken 12069 times.
✗ Branch 1 not taken.
|
12069 | */ |
| 7832 | exit(MYSQLD_ABORT_EXIT); | ||
| 7833 | } | ||
| 7834 | |||
| 7835 | if (init_common_variables()) { | ||
| 7836 | setup_error_log(); | ||
| 7837 |
1/2✓ Branch 0 taken 12069 times.
✗ Branch 1 not taken.
|
12069 | unireg_abort(MYSQLD_ABORT_EXIT); // Will do exit |
| 7838 | } | ||
| 7839 | 12069 | ||
| 7840 | keyring_lockable_init(); | ||
| 7841 | 12069 | ||
| 7842 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12069 times.
|
12069 | /* |
| 7843 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12069 times.
|
12069 | Install server's my_abort routine to assure my_aborts prints signal info |
| 7844 | sequentially without sudden termination. | ||
| 7845 | */ | ||
| 7846 | set_my_abort(my_server_abort); | ||
| 7847 | |||
| 7848 | size_t guardize = 0; | ||
| 7849 | #ifndef _WIN32 | ||
| 7850 | int retval = pthread_attr_getguardsize(&connection_attrib, &guardize); | ||
| 7851 | assert(retval == 0); | ||
| 7852 | if (retval != 0) guardize = my_thread_stack_size; | ||
| 7853 | #endif | ||
| 7854 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12069 times.
|
12069 | |
| 7855 | #if defined(__ia64__) || defined(__ia64) | ||
| 7856 | ✗ | /* | |
| 7857 | Peculiar things with ia64 platforms - it seems we only have half the | ||
| 7858 | stack size in reality, so we have to double it here | ||
| 7859 | */ | ||
| 7860 | guardize = my_thread_stack_size; | ||
| 7861 | 12069 | #endif | |
| 7862 | 12069 | ||
| 7863 | if (0 != my_thread_attr_setstacksize(&connection_attrib, | ||
| 7864 | my_thread_stack_size + guardize)) { | ||
| 7865 |
2/4✓ Branch 0 taken 12069 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12069 times.
|
12069 | assert(false); |
| 7866 | ✗ | } | |
| 7867 | |||
| 7868 | { | ||
| 7869 | /* Retrieve used stack size; Needed for checking stack overflows */ | ||
| 7870 | size_t stack_size = 0; | ||
| 7871 | ✗ | my_thread_attr_getstacksize(&connection_attrib, &stack_size); | |
| 7872 | |||
| 7873 | /* We must check if stack_size = 0 as Solaris 2.9 can return 0 here */ | ||
| 7874 | if (stack_size && stack_size < (my_thread_stack_size + guardize)) { | ||
| 7875 | LogErr(WARNING_LEVEL, ER_STACKSIZE_UNEXPECTED, | ||
| 7876 | my_thread_stack_size + guardize, (long)stack_size); | ||
| 7877 |
1/2✓ Branch 0 taken 12069 times.
✗ Branch 1 not taken.
|
12069 | #if defined(__ia64__) || defined(__ia64) |
| 7878 | 12069 | my_thread_stack_size = stack_size / 2; | |
| 7879 | #else | ||
| 7880 | my_thread_stack_size = static_cast<ulong>(stack_size - guardize); | ||
| 7881 | #endif | ||
| 7882 | } | ||
| 7883 |
3/4✓ Branch 0 taken 298 times.
✓ Branch 1 taken 11771 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 298 times.
|
12069 | } |
| 7884 | ✗ | ||
| 7885 | ✗ | #ifndef NDEBUG | |
| 7886 | test_lc_time_sz(); | ||
| 7887 | srand(static_cast<uint>(time(nullptr))); | ||
| 7888 |
6/8✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12063 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 12069 times.
|
12073 | #endif |
| 7889 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
4 | |
| 7890 | #if !defined(_WIN32) | ||
| 7891 | ✗ | ||
| 7892 | if (opt_initialize && opt_daemonize) { | ||
| 7893 | fprintf(stderr, "Initialize and daemon options are incompatible.\n"); | ||
| 7894 |
3/4✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12063 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
12069 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 7895 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
|
6 | } |
| 7896 | ✗ | ||
| 7897 | ✗ | if (opt_daemonize && log_error_dest == disabled_my_option && | |
| 7898 | (isatty(STDOUT_FILENO) || isatty(STDERR_FILENO))) { | ||
| 7899 | // Just use the default in this case. | ||
| 7900 |
3/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 5 times.
|
6 | log_error_dest = ""; |
| 7901 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | } |
| 7902 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
1 | |
| 7903 | if (opt_daemonize && !opt_validate_config) { | ||
| 7904 | if (chdir("/") < 0) { | ||
| 7905 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 3 times.
|
5 | LogErr(ERROR_LEVEL, ER_CANNOT_CHANGE_TO_ROOT_DIR, strerror(errno)); |
| 7906 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7907 | } | ||
| 7908 | |||
| 7909 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
2 | if ((pipe_write_fd = mysqld::runtime::mysqld_daemonize()) < -1) { |
| 7910 | LogErr(ERROR_LEVEL, ER_FAILED_START_MYSQLD_DAEMON); | ||
| 7911 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 7912 | } | ||
| 7913 | |||
| 7914 | if (pipe_write_fd < 0) { | ||
| 7915 | 3 | // This is the launching process and the daemon appears to have | |
| 7916 | // started ok (Need to call unireg_abort with success here to | ||
| 7917 | // clean up resources in the launching process. | ||
| 7918 | unireg_abort(MYSQLD_SUCCESS_EXIT); | ||
| 7919 | } | ||
| 7920 |
1/2✓ Branch 0 taken 12066 times.
✗ Branch 1 not taken.
|
12066 | |
| 7921 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12066 times.
|
12066 | // Need to update the value of current_pid so that it reflects the |
| 7922 | // pid of the daemon (the previous value was set by unireg_init() | ||
| 7923 | ✗ | // while still in the launcher process. | |
| 7924 | current_pid = static_cast<ulong>(getpid()); | ||
| 7925 | } | ||
| 7926 | #endif | ||
| 7927 | ✗ | ||
| 7928 | #ifndef _WIN32 | ||
| 7929 | user_info = check_user(mysqld_user); | ||
| 7930 | ✗ | if (!user_info.IsVoid()) { | |
| 7931 | ✗ | #if HAVE_CHOWN | |
| 7932 | if (unlikely(opt_initialize)) { | ||
| 7933 | /* need to change the owner of the freshly created data directory */ | ||
| 7934 | MY_STAT stat; | ||
| 7935 | ✗ | char errbuf[MYSYS_STRERROR_SIZE]; | |
| 7936 | ✗ | bool must_chown = true; | |
| 7937 | ✗ | ||
| 7938 | /* fetch the directory's owner */ | ||
| 7939 | ✗ | if (!my_stat(mysql_real_data_home, &stat, MYF(0))) { | |
| 7940 | ✗ | LogErr(INFORMATION_LEVEL, ER_CANT_STAT_DATADIR, my_errno(), | |
| 7941 | ✗ | my_strerror(errbuf, sizeof(errbuf), my_errno())); | |
| 7942 | ✗ | } | |
| 7943 | /* Don't change it if it's already the same as SElinux stops this */ | ||
| 7944 | else if (stat.st_uid == user_info.pw_uid && | ||
| 7945 | stat.st_gid == user_info.pw_gid) | ||
| 7946 | must_chown = false; | ||
| 7947 | |||
| 7948 | ✗ | if (must_chown && | |
| 7949 | ✗ | chown(mysql_real_data_home, user_info.pw_uid, user_info.pw_gid)) { | |
| 7950 | LogErr(ERROR_LEVEL, ER_CANT_CHOWN_DATADIR, mysqld_user); | ||
| 7951 | unireg_abort(1); | ||
| 7952 | ✗ | } | |
| 7953 | } | ||
| 7954 | #endif | ||
| 7955 | |||
| 7956 | #if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) | ||
| 7957 | if (locked_in_memory) // getuid() == 0 here | ||
| 7958 | set_effective_user(user_info); | ||
| 7959 | else | ||
| 7960 |
4/6✓ Branch 0 taken 12061 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 12061 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12061 times.
|
12066 | #endif |
| 7961 | set_user(mysqld_user, user_info); | ||
| 7962 | 5 | } | |
| 7963 | #endif // !_WIN32 | ||
| 7964 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | |
| 7965 | 5 | /* | |
| 7966 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
|
5 | initiate key migration if any one of the migration specific |
| 7967 | options are provided. | ||
| 7968 | */ | ||
| 7969 | if (opt_keyring_migration_source || opt_keyring_migration_destination || | ||
| 7970 | migrate_connect_options) { | ||
| 7971 | ✗ | int exit_state = MYSQLD_ABORT_EXIT; | |
| 7972 | ✗ | while (true) { | |
| 7973 | ✗ | Migrate_keyring mk; | |
| 7974 | ✗ | my_getopt_skip_unknown = true; | |
| 7975 | if (mk.init(remaining_argc, remaining_argv, opt_keyring_migration_source, | ||
| 7976 | opt_keyring_migration_destination, opt_keyring_migration_user, | ||
| 7977 |
2/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
|
5 | opt_keyring_migration_host, opt_keyring_migration_password, |
| 7978 | ✗ | opt_keyring_migration_socket, opt_keyring_migration_port, | |
| 7979 | ✗ | opt_keyring_migration_to_component)) { | |
| 7980 | ✗ | LogErr(ERROR_LEVEL, ER_KEYRING_MIGRATION_FAILED); | |
| 7981 | ✗ | log_error_dest = "stderr"; | |
| 7982 | flush_error_log_messages(); | ||
| 7983 | break; | ||
| 7984 | 5 | } | |
| 7985 |
8/16✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
|
5 | |
| 7986 | 5 | if (mk.execute()) { | |
| 7987 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | LogErr(ERROR_LEVEL, ER_KEYRING_MIGRATION_FAILED); |
| 7988 | 5 | log_error_dest = "stderr"; | |
| 7989 | 5 | flush_error_log_messages(); | |
| 7990 | 5 | break; | |
| 7991 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
5 | } |
| 7992 | |||
| 7993 | my_getopt_skip_unknown = false; | ||
| 7994 | LogErr(INFORMATION_LEVEL, ER_KEYRING_MIGRATION_SUCCESSFUL); | ||
| 7995 | log_error_dest = "stderr"; | ||
| 7996 | flush_error_log_messages(); | ||
| 7997 |
4/4✓ Branch 0 taken 12043 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12058 times.
|
24104 | exit_state = MYSQLD_SUCCESS_EXIT; |
| 7998 |
3/4✓ Branch 0 taken 12043 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 12040 times.
|
12043 | break; |
| 7999 | } | ||
| 8000 | unireg_abort(exit_state); | ||
| 8001 |
9/18✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
|
3 | } |
| 8002 | |||
| 8003 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
3 | /* |
| 8004 | We have enough space for fiddling with the argv, continue | ||
| 8005 | */ | ||
| 8006 | if (!(is_help_or_validate_option()) && | ||
| 8007 | my_setwd(mysql_real_data_home, MYF(0))) { | ||
| 8008 | char errbuf[MYSYS_STRERROR_SIZE]; | ||
| 8009 | |||
| 8010 | LogErr(ERROR_LEVEL, ER_CANT_SET_DATA_DIR, mysql_real_data_home, errno, | ||
| 8011 | my_strerror(errbuf, sizeof(errbuf), errno)); | ||
| 8012 | unireg_abort(MYSQLD_ABORT_EXIT); /* purecov: inspected */ | ||
| 8013 | } | ||
| 8014 | |||
| 8015 | /* | ||
| 8016 | The subsequent calls may take a long time : e.g. innodb log read. | ||
| 8017 | Thus set the long running service control manager timeout | ||
| 8018 | */ | ||
| 8019 | #if defined(_WIN32) | ||
| 8020 | if (windows_service) { | ||
| 8021 | if (setup_service_status_cmd_processed_handle()) | ||
| 8022 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8023 |
1/2✓ Branch 0 taken 12058 times.
✗ Branch 1 not taken.
|
12058 | |
| 8024 | char buf[32]; | ||
| 8025 |
2/6✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12058 | snprintf(buf, sizeof(buf), "T %lu", slow_start_timeout); |
| 8026 | Service_status_msg msg(buf); | ||
| 8027 |
2/2✓ Branch 0 taken 310 times.
✓ Branch 1 taken 11458 times.
|
11768 | send_service_status(msg); |
| 8028 |
8/16✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 310 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 310 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 310 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 310 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 310 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 310 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 310 times.
✗ Branch 15 not taken.
|
310 | } |
| 8029 | #endif | ||
| 8030 | |||
| 8031 | /* Determine default TCP port and unix socket name */ | ||
| 8032 | set_ports(); | ||
| 8033 | |||
| 8034 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | if (init_server_components()) unireg_abort(MYSQLD_ABORT_EXIT); |
| 8035 |
2/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11768 times.
|
23536 | |
| 8036 |
2/4✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11768 times.
|
11768 | if (!server_id_supplied) |
| 8037 | ✗ | LogErr(INFORMATION_LEVEL, ER_WARN_NO_SERVERID_SPECIFIED); | |
| 8038 | |||
| 8039 | /* Server generates uuid after innodb is initialized. But during | ||
| 8040 | initialization, if tablespaces like system, redo, temporary are encrypted, | ||
| 8041 | they are initialized with "empty" UUID. Now UUID is available, fix the | ||
| 8042 | empty UUID of such tablespaces now */ | ||
| 8043 | if (innodb_hton != nullptr) { | ||
| 8044 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | if (innodb_hton->fix_tablespaces_empty_uuid != nullptr && |
| 8045 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | innodb_hton->fix_tablespaces_empty_uuid()) { |
| 8046 | sql_print_error( | ||
| 8047 | "Fixing empty UUID with InnoDB Engine failed. Please" | ||
| 8048 | " check if keyring plugin is loaded and execute" | ||
| 8049 | " \"ALTER INSTANCE ROTATE INNODB MASTER KEY\""); | ||
| 8050 | } | ||
| 8051 | // Only now, that we have server_uuid initialized we can | ||
| 8052 | // instruct encryption threads to do some work | ||
| 8053 | if (innodb_hton->fix_default_table_encryption != nullptr) { | ||
| 8054 | innodb_hton->fix_default_table_encryption( | ||
| 8055 | global_system_variables.default_table_encryption, true); | ||
| 8056 | } | ||
| 8057 | } | ||
| 8058 | |||
| 8059 | /* | ||
| 8060 | Add server_uuid to the sid_map. This must be done after | ||
| 8061 | server_uuid has been initialized in init_server_auto_options and | ||
| 8062 | after the binary log (and sid_map file) has been initialized in | ||
| 8063 | init_server_components(). | ||
| 8064 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | |
| 8065 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | No error message is needed: init_sid_map() prints a message. |
| 8066 |
1/2✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
|
11768 | |
| 8067 | Strictly speaking, this is not currently needed when | ||
| 8068 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 11768 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
11768 | opt_bin_log==0, since the variables that gtid_state->init |
| 8069 | initializes are not currently used in that case. But we call it | ||
| 8070 |
3/4✓ Branch 0 taken 11478 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 11478 times.
✗ Branch 3 not taken.
|
11768 | regardless to avoid possible future bugs if gtid_state ever |
| 8071 | needs to do anything else. | ||
| 8072 |
2/6✓ Branch 0 taken 11478 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11478 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
11478 | */ |
| 8073 | global_sid_lock->wrlock(); | ||
| 8074 | int gtid_ret = gtid_state->init(); | ||
| 8075 |
2/2✓ Branch 0 taken 11224 times.
✓ Branch 1 taken 544 times.
|
11768 | global_sid_lock->unlock(); |
| 8076 | |||
| 8077 | if (gtid_ret) unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8078 | |||
| 8079 | if (!opt_initialize && !opt_initialize_insecure) { | ||
| 8080 | // Initialize executed_gtids from mysql.gtid_executed table. | ||
| 8081 | 11224 | if (gtid_state->read_gtid_executed_from_table() == -1) unireg_abort(1); | |
| 8082 | 11224 | } | |
| 8083 | |||
| 8084 | 11224 | if (opt_bin_log) { | |
| 8085 | /* | ||
| 8086 | 11224 | Initialize GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED from | |
| 8087 | gtid_executed table and binlog files during server startup. | ||
| 8088 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | */ |
| 8089 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | Gtid_set *executed_gtids = |
| 8090 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | const_cast<Gtid_set *>(gtid_state->get_executed_gtids()); |
| 8091 | Gtid_set *lost_gtids = const_cast<Gtid_set *>(gtid_state->get_lost_gtids()); | ||
| 8092 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | Gtid_set *gtids_only_in_table = |
| 8093 | const_cast<Gtid_set *>(gtid_state->get_gtids_only_in_table()); | ||
| 8094 | Gtid_set *previous_gtids_logged = | ||
| 8095 | const_cast<Gtid_set *>(gtid_state->get_previous_gtids_logged()); | ||
| 8096 | |||
| 8097 | ✗ | Gtid_set purged_gtids_from_binlog(global_sid_map, global_sid_lock); | |
| 8098 | Gtid_set gtids_in_binlog(global_sid_map, global_sid_lock); | ||
| 8099 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | Gtid_set gtids_in_binlog_not_in_table(global_sid_map, global_sid_lock); |
| 8100 | |||
| 8101 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | if (mysql_bin_log.init_gtid_sets( |
| 8102 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | >ids_in_binlog, &purged_gtids_from_binlog, |
| 8103 | opt_source_verify_checksum, true /*true=need lock*/, | ||
| 8104 |
5/6✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 450 times.
✓ Branch 3 taken 10774 times.
✓ Branch 4 taken 87 times.
✓ Branch 5 taken 11137 times.
|
11674 | nullptr /*trx_parser*/, nullptr /*partial_trx*/, |
| 8105 |
3/4✓ Branch 0 taken 450 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 363 times.
|
450 | true /*is_server_starting*/)) |
| 8106 |
1/2✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
|
87 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 8107 |
3/4✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 70 times.
✓ Branch 3 taken 17 times.
|
87 | |
| 8108 |
1/2✓ Branch 0 taken 70 times.
✗ Branch 1 not taken.
|
70 | global_sid_lock->wrlock(); |
| 8109 | |||
| 8110 | purged_gtids_from_binlog.dbug_print("purged_gtids_from_binlog"); | ||
| 8111 | gtids_in_binlog.dbug_print("gtids_in_binlog"); | ||
| 8112 | |||
| 8113 | if (!gtids_in_binlog.is_empty() && | ||
| 8114 | !gtids_in_binlog.is_subset(executed_gtids)) { | ||
| 8115 | gtids_in_binlog_not_in_table.add_gtid_set(>ids_in_binlog); | ||
| 8116 | if (!executed_gtids->is_empty()) | ||
| 8117 | gtids_in_binlog_not_in_table.remove_gtid_set(executed_gtids); | ||
| 8118 | /* | ||
| 8119 | Save unsaved GTIDs into gtid_executed table, in the following | ||
| 8120 | four cases: | ||
| 8121 | 1. the upgrade case. | ||
| 8122 | 2. the case that a slave is provisioned from a backup of | ||
| 8123 |
2/4✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 87 times.
|
87 | the master and the slave is cleaned by RESET MASTER |
| 8124 | ✗ | and RESET SLAVE before this. | |
| 8125 | ✗ | 3. the case that no binlog rotation happened from the | |
| 8126 | last RESET MASTER on the server before it crashes. | ||
| 8127 |
1/2✓ Branch 0 taken 87 times.
✗ Branch 1 not taken.
|
87 | 4. The set of GTIDs of the last binlog is not saved into the |
| 8128 | gtid_executed table if server crashes, so we save it into | ||
| 8129 | gtid_executed table and executed_gtids during recovery | ||
| 8130 | from the crash. | ||
| 8131 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | */ |
| 8132 | ✗ | if (gtid_state->save(>ids_in_binlog_not_in_table) == -1) { | |
| 8133 | ✗ | global_sid_lock->unlock(); | |
| 8134 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8135 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | } |
| 8136 | executed_gtids->add_gtid_set(>ids_in_binlog_not_in_table); | ||
| 8137 | } | ||
| 8138 | |||
| 8139 | /* gtids_only_in_table= executed_gtids - gtids_in_binlog */ | ||
| 8140 | if (gtids_only_in_table->add_gtid_set(executed_gtids) != RETURN_STATUS_OK) { | ||
| 8141 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | global_sid_lock->unlock(); |
| 8142 |
3/6✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11224 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11224 times.
|
22448 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 8143 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | } |
| 8144 | gtids_only_in_table->remove_gtid_set(>ids_in_binlog); | ||
| 8145 | ✗ | /* | |
| 8146 | ✗ | lost_gtids = executed_gtids - | |
| 8147 | (gtids_in_binlog - purged_gtids_from_binlog) | ||
| 8148 | = gtids_only_in_table + purged_gtids_from_binlog; | ||
| 8149 | */ | ||
| 8150 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | assert(lost_gtids->is_empty()); |
| 8151 | if (lost_gtids->add_gtid_set(gtids_only_in_table) != RETURN_STATUS_OK || | ||
| 8152 | ✗ | lost_gtids->add_gtid_set(&purged_gtids_from_binlog) != | |
| 8153 | ✗ | RETURN_STATUS_OK) { | |
| 8154 | global_sid_lock->unlock(); | ||
| 8155 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8156 | } | ||
| 8157 | |||
| 8158 | /* Prepare previous_gtids_logged for next binlog */ | ||
| 8159 | if (previous_gtids_logged->add_gtid_set(>ids_in_binlog) != | ||
| 8160 | RETURN_STATUS_OK) { | ||
| 8161 | global_sid_lock->unlock(); | ||
| 8162 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8163 | } | ||
| 8164 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | |
| 8165 | /* | ||
| 8166 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | Write the previous set of gtids at this point because during |
| 8167 | the creation of the binary log this is not done as we cannot | ||
| 8168 | 11224 | move the init_gtid_sets() to a place before opening the binary | |
| 8169 | 11224 | log. This requires some investigation. | |
| 8170 | |||
| 8171 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11224 times.
|
11224 | /Alfranio |
| 8172 | ✗ | */ | |
| 8173 | Previous_gtids_log_event prev_gtids_ev(>ids_in_binlog); | ||
| 8174 | |||
| 8175 | global_sid_lock->unlock(); | ||
| 8176 | |||
| 8177 | (prev_gtids_ev.common_footer)->checksum_alg = | ||
| 8178 | static_cast<enum_binlog_checksum_alg>(binlog_checksum_options); | ||
| 8179 | |||
| 8180 | if (mysql_bin_log.write_event_to_binlog_and_sync(&prev_gtids_ev)) | ||
| 8181 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8182 | |||
| 8183 | // run auto purge member function. It will evaluate auto purge controls | ||
| 8184 | // and configuration, calculate which log files are to be purged, and | ||
| 8185 | // if any file is to be purged, it will purge it. This is all encapsulated | ||
| 8186 |
2/4✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11224 times.
✗ Branch 3 not taken.
|
11224 | // insiude the auto purge member function. |
| 8187 |
1/2✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
|
11224 | // |
| 8188 | ✗ | // Note on the DBUG_EVALUATE_IF usage below: | |
| 8189 | ✗ | // - when compiling it out: the condition evaluates to true, thus | |
| 8190 | // mysql_bin_log.auto_purge_at_server_startup() runs | ||
| 8191 |
3/4✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11220 times.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
|
11224 | // - when "expire_logs_always_at_start" is set: evaluates to false, |
| 8192 | // thus mysql_bin_log.purge_logs_before_date() runs | ||
| 8193 |
4/6✓ Branch 0 taken 11224 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1511 times.
✓ Branch 3 taken 9713 times.
✓ Branch 4 taken 1511 times.
✗ Branch 5 not taken.
|
11224 | // - when "expire_logs_always_at_start" is not set: evaluates to true, |
| 8194 | 11224 | // this mysql_bin_log.auto_purge_at_server_startup() runs | |
| 8195 | if (DBUG_EVALUATE_IF("expire_logs_always_at_start", false, true)) | ||
| 8196 |
3/6✓ Branch 0 taken 11768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 11758 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
11768 | mysql_bin_log.auto_purge_at_server_startup(); |
| 8197 |
3/6✓ Branch 0 taken 11748 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 11733 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
11758 | else if (expire_logs_days > 0 || binlog_expire_logs_seconds > 0) |
| 8198 | mysql_bin_log.purge_logs_before_date(time(nullptr), true); | ||
| 8199 | |||
| 8200 | if (binlog_space_limit) mysql_bin_log.purge_logs_by_size(true); | ||
| 8201 | |||
| 8202 | (void)RUN_HOOK(server_state, after_engine_recovery, (nullptr)); | ||
| 8203 | } | ||
| 8204 | |||
| 8205 | if (init_ssl_communication()) unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8206 | if (network_init()) unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8207 | |||
| 8208 | #ifdef _WIN32 | ||
| 8209 | if (opt_require_secure_transport && !opt_enable_shared_memory && | ||
| 8210 | 11733 | !have_ssl() && !opt_initialize) { | |
| 8211 | 11733 | LogErr(ERROR_LEVEL, ER_TRANSPORTS_WHAT_TRANSPORTS); | |
| 8212 | 11733 | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 8213 | } | ||
| 8214 | 11733 | #endif | |
| 8215 | |||
| 8216 | 11733 | /* | |
| 8217 | Initialize my_str_malloc(), my_str_realloc() and my_str_free() | ||
| 8218 | */ | ||
| 8219 |
2/2✓ Branch 0 taken 11443 times.
✓ Branch 1 taken 290 times.
|
11733 | my_str_malloc = &my_str_malloc_mysqld; |
| 8220 |
2/4✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11443 times.
|
11443 | my_str_free = &my_str_free_mysqld; |
| 8221 | my_str_realloc = &my_str_realloc_mysqld; | ||
| 8222 | |||
| 8223 | error_handler_hook = my_message_sql; | ||
| 8224 |
3/4✓ Branch 0 taken 11443 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 11443 times.
✗ Branch 3 not taken.
|
11733 | |
| 8225 | bool abort = false; | ||
| 8226 | 11733 | ||
| 8227 | /* Save pid of this process in a file */ | ||
| 8228 | if (!opt_initialize) { | ||
| 8229 | if (create_pid_file()) abort = true; | ||
| 8230 | } | ||
| 8231 |
5/8✓ Branch 0 taken 11443 times.
✓ Branch 1 taken 290 times.
✓ Branch 2 taken 11443 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11443 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11733 times.
|
23466 | |
| 8232 |
2/4✓ Branch 0 taken 11733 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11733 times.
|
11733 | /* Read the optimizer cost model configuration tables */ |
| 8233 | ✗ | if (!opt_initialize) reload_optimizer_cost_constants(); | |
| 8234 | |||
| 8235 | if ( | ||
| 8236 | /* | ||
| 8237 |
1/2✓ Branch 0 taken 11733 times.
✗ Branch 1 not taken.
|
11733 | Read components table to restore previously installed components. This |
| 8238 | requires read access to mysql.component table. | ||
| 8239 | 11733 | */ | |
| 8240 | (!opt_initialize && mysql_component_infrastructure_init()) || | ||
| 8241 | mysql_rm_tmp_tables()) { | ||
| 8242 | abort = true; | ||
| 8243 | } | ||
| 8244 | |||
| 8245 | /* we do want to exit if there are any other unknown options */ | ||
| 8246 | 11733 | if (remaining_argc > 1) { | |
| 8247 | int ho_error; | ||
| 8248 |
3/4✓ Branch 0 taken 11733 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 11703 times.
|
11733 | struct my_option no_opts[] = {{nullptr, 0, nullptr, nullptr, nullptr, |
| 8249 | nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, | ||
| 8250 | 30 | nullptr, 0, nullptr}}; | |
| 8251 | /* | ||
| 8252 | We need to eat any 'loose' arguments first before we conclude | ||
| 8253 | 11703 | that there are unprocessed options. | |
| 8254 | 11703 | */ | |
| 8255 | 11703 | my_getopt_skip_unknown = false; | |
| 8256 | |||
| 8257 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 11700 times.
|
11703 | if ((ho_error = handle_options(&remaining_argc, &remaining_argv, no_opts, |
| 8258 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | mysqld_get_one_option))) |
| 8259 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | abort = true; |
| 8260 | 3 | else { | |
| 8261 | /* Add back the program name handle_options removes */ | ||
| 8262 | remaining_argc++; | ||
| 8263 | remaining_argv--; | ||
| 8264 | my_getopt_skip_unknown = true; | ||
| 8265 |
7/8✓ Branch 0 taken 11700 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 11692 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 11691 times.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 11691 times.
|
11733 | |
| 8266 |
10/18✓ Branch 0 taken 1 times.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
34 | if (remaining_argc > 1) { |
| 8267 | 34 | LogErr(ERROR_LEVEL, ER_EXCESS_ARGUMENTS, remaining_argv[1]); | |
| 8268 | 34 | LogErr(INFORMATION_LEVEL, ER_VERBOSE_HINT); | |
| 8269 | abort = true; | ||
| 8270 | } | ||
| 8271 | } | ||
| 8272 | } | ||
| 8273 | |||
| 8274 | if (abort || acl_init(opt_noacl)) { | ||
| 8275 |
3/4✓ Branch 0 taken 290 times.
✓ Branch 1 taken 11435 times.
✓ Branch 2 taken 290 times.
✗ Branch 3 not taken.
|
11725 | if (!abort) LogErr(ERROR_LEVEL, ER_PRIVILEGE_SYSTEM_INIT_FAILED); |
| 8276 | abort = true; | ||
| 8277 |
6/8✓ Branch 0 taken 11691 times.
✓ Branch 1 taken 34 times.
✓ Branch 2 taken 11691 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11691 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 34 times.
✓ Branch 7 taken 11691 times.
|
23416 | opt_noacl = true; |
| 8278 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
11691 | } |
| 8279 | 34 | ||
| 8280 | /* | ||
| 8281 |
1/2✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
|
34 | if running with --initialize, explicitly allocate the memory |
| 8282 | to be used by ACL objects. | ||
| 8283 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
34 | */ |
| 8284 | if (opt_initialize) init_acl_memory(); | ||
| 8285 | |||
| 8286 | if (abort || my_tz_init((THD *)nullptr, default_tz_name, opt_initialize) || | ||
| 8287 | grant_init(opt_noacl)) { | ||
| 8288 | set_connection_events_loop_aborted(true); | ||
| 8289 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
11691 | |
| 8290 | ✗ | delete_pid_file(MYF(MY_WME)); | |
| 8291 | |||
| 8292 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8293 | } | ||
| 8294 | |||
| 8295 | /* | ||
| 8296 | Bootstrap the dynamic privilege service implementation | ||
| 8297 | */ | ||
| 8298 |
7/8✓ Branch 0 taken 11405 times.
✓ Branch 1 taken 286 times.
✓ Branch 2 taken 11405 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 152 times.
✓ Branch 5 taken 11253 times.
✓ Branch 6 taken 11256 times.
✓ Branch 7 taken 435 times.
|
11843 | if (dynamic_privilege_init()) { |
| 8299 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 149 times.
|
152 | LogErr(WARNING_LEVEL, ER_PERSISTENT_PRIVILEGES_BOOTSTRAP); |
| 8300 |
1/2✓ Branch 0 taken 11256 times.
✗ Branch 1 not taken.
|
11256 | } |
| 8301 | |||
| 8302 |
2/2✓ Branch 0 taken 11391 times.
✓ Branch 1 taken 300 times.
|
11691 | /* |
| 8303 |
1/2✓ Branch 0 taken 11391 times.
✗ Branch 1 not taken.
|
11391 | In the case of upgrade, the bootstrap thread would have already initialized |
| 8304 | the structures necessary for federated server from mysql.servers table. | ||
| 8305 | Hence we need not initialize them again here. | ||
| 8306 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | */ |
| 8307 | if (!opt_initialize && (dd::upgrade::no_server_upgrade_required() || | ||
| 8308 |
2/2✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11405 times.
|
11691 | opt_upgrade_mode == UPGRADE_MINIMAL)) |
| 8309 | servers_init(nullptr); | ||
| 8310 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | |
| 8311 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | if (!opt_noacl) { |
| 8312 | udf_read_functions_table(); | ||
| 8313 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | } |
| 8314 | |||
| 8315 | init_status_vars(); | ||
| 8316 |
2/2✓ Branch 0 taken 11405 times.
✓ Branch 1 taken 286 times.
|
11691 | /* If running with --initialize, do not start replication. */ |
| 8317 | if (opt_initialize) opt_skip_replica_start = true; | ||
| 8318 |
1/2✓ Branch 0 taken 11405 times.
✗ Branch 1 not taken.
|
11405 | |
| 8319 | check_binlog_cache_size(nullptr); | ||
| 8320 | check_binlog_stmt_cache_size(nullptr); | ||
| 8321 | |||
| 8322 | binlog_unsafe_map_init(); | ||
| 8323 | |||
| 8324 |
1/2✓ Branch 0 taken 11405 times.
✗ Branch 1 not taken.
|
11405 | /* If running with --initialize, do not start replication. */ |
| 8325 | if (!opt_initialize) { | ||
| 8326 | // Make @@replica_skip_errors show the nice human-readable value. | ||
| 8327 | set_replica_skip_errors(&opt_replica_skip_errors); | ||
| 8328 | /* | ||
| 8329 |
2/2✓ Branch 0 taken 11397 times.
✓ Branch 1 taken 8 times.
|
11405 | Group replication filters should be discarded before init_replica(), |
| 8330 |
1/2✓ Branch 0 taken 11397 times.
✗ Branch 1 not taken.
|
11397 | otherwise the pre-configured filters will be referenced by group |
| 8331 | replication channels. | ||
| 8332 | */ | ||
| 8333 | rpl_channel_filters.discard_group_replication_filters(); | ||
| 8334 | |||
| 8335 | /* | ||
| 8336 | init_replica() must be called after the thread keys are created. | ||
| 8337 | */ | ||
| 8338 | if (server_id != 0) | ||
| 8339 | init_replica(); /* Ignoring errors while configuring replication. */ | ||
| 8340 | |||
| 8341 | /* | ||
| 8342 | If the user specifies a per-channel replication filter through a | ||
| 8343 | command-line option (or in a configuration file) for a slave | ||
| 8344 |
1/2✓ Branch 0 taken 11405 times.
✗ Branch 1 not taken.
|
11405 | replication channel which does not exist as of now (i.e not |
| 8345 | present in slave info tables yet), then the per-channel | ||
| 8346 | replication filter is discarded with a warning. | ||
| 8347 | If the user specifies a per-channel replication filter through | ||
| 8348 | a command-line option (or in a configuration file) for group | ||
| 8349 | replication channels 'group_replication_recovery' and | ||
| 8350 | 'group_replication_applier' which is disallowed, then the | ||
| 8351 | per-channel replication filter is discarded with a warning. | ||
| 8352 | */ | ||
| 8353 | rpl_channel_filters.discard_all_unattached_filters(); | ||
| 8354 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | } |
| 8355 | |||
| 8356 | #ifdef WITH_LOCK_ORDER | ||
| 8357 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | if (!opt_initialize) { |
| 8358 | LO_activate(); | ||
| 8359 |
4/6✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1514 times.
✓ Branch 3 taken 10177 times.
✓ Branch 4 taken 1514 times.
✗ Branch 5 not taken.
|
11691 | } |
| 8360 | #endif /* WITH_LOCK_ORDER */ | ||
| 8361 |
5/8✓ Branch 0 taken 11391 times.
✓ Branch 1 taken 300 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11391 times.
✓ Branch 4 taken 11691 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11691 times.
|
11691 | |
| 8362 | ✗ | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | |
| 8363 | initialize_performance_schema_acl(opt_initialize); | ||
| 8364 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 8365 | |||
| 8366 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | initialize_information_schema_acl(); |
| 8367 | |||
| 8368 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
23382 | (void)RUN_HOOK(server_state, after_recovery, (nullptr)); |
| 8369 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
11691 | |
| 8370 | if (Events::init(opt_noacl || opt_initialize)) | ||
| 8371 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 8372 | ✗ | ||
| 8373 | #ifndef _WIN32 | ||
| 8374 | // Start signal handler thread. | ||
| 8375 |
1/2✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
|
11691 | start_signal_handler(); |
| 8376 | #endif | ||
| 8377 | if (opt_authentication_policy && | ||
| 8378 |
2/4✓ Branch 0 taken 11691 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11691 times.
|
11691 | validate_authentication_policy(opt_authentication_policy)) { |
| 8379 | ✗ | /* --authentication_policy is set to invalid value */ | |
| 8380 | ✗ | LogErr(ERROR_LEVEL, ER_INVALID_AUTHENTICATION_POLICY); | |
| 8381 | ✗ | return 1; | |
| 8382 | } else { | ||
| 8383 | /* update the value */ | ||
| 8384 | update_authentication_policy(); | ||
| 8385 | } | ||
| 8386 | /* set all persistent options */ | ||
| 8387 |
1/2✓ Branch 0 taken 11405 times.
✗ Branch 1 not taken.
|
11691 | if (persisted_variables_cache.set_persisted_options(false)) { |
| 8388 | LogErr(ERROR_LEVEL, ER_CANT_SET_UP_PERSISTED_VALUES); | ||
| 8389 | flush_error_log_messages(); | ||
| 8390 | return 1; | ||
| 8391 | } | ||
| 8392 | |||
| 8393 | 11405 | /* | |
| 8394 |
2/4✓ Branch 0 taken 11405 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11405 times.
|
11405 | Invoke the bootstrap thread, if required. |
| 8395 | */ | ||
| 8396 | ✗ | process_bootstrap(); | |
| 8397 | |||
| 8398 | /* | ||
| 8399 | Event must be invoked after error_handler_hook is assigned to | ||
| 8400 | my_message_sql, otherwise my_message will not cause the event to abort. | ||
| 8401 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11401 times.
|
11405 | */ |
| 8402 | void *argv_p = argv; | ||
| 8403 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
4 | if (mysql_audit_notify(AUDIT_EVENT(MYSQL_AUDIT_SERVER_STARTUP_STARTUP), |
| 8404 | static_cast<const char **>(argv_p), argc)) | ||
| 8405 |
0/2✗ Branch 0 not taken.
✗ Branch 1 not taken.
|
4 | unireg_abort(MYSQLD_ABORT_EXIT); |
| 8406 | |||
| 8407 | #ifdef _WIN32 | ||
| 8408 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | create_shutdown_and_restart_thread(); |
| 8409 | #endif | ||
| 8410 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | if (mysqld_process_must_end_at_startup) { |
| 8411 | #if !defined(_WIN32) | ||
| 8412 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
22802 | if (opt_daemonize) mysqld::runtime::signal_parent(pipe_write_fd, 1); |
| 8413 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | #endif |
| 8414 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | unireg_abort(MYSQLD_SUCCESS_EXIT); |
| 8415 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | } |
| 8416 |
2/4✗ Branch 0 not taken.
✓ Branch 1 taken 11401 times.
✓ Branch 2 taken 11401 times.
✗ Branch 3 not taken.
|
11401 | |
| 8417 | start_handle_manager(); | ||
| 8418 | |||
| 8419 | create_compress_gtid_table_thread(); | ||
| 8420 | |||
| 8421 | LogEvent() | ||
| 8422 | .type(LOG_TYPE_ERROR) | ||
| 8423 | .subsys(LOG_SUBSYSTEM_TAG) | ||
| 8424 |
4/4✓ Branch 0 taken 11380 times.
✓ Branch 1 taken 21 times.
✓ Branch 2 taken 27 times.
✓ Branch 3 taken 11353 times.
|
11401 | .prio(SYSTEM_LEVEL) |
| 8425 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
54 | .lookup(ER_SERVER_STARTUP_MSG, my_progname, server_version, |
| 8426 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | #ifdef HAVE_SYS_UN_H |
| 8427 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | (opt_initialize ? "" : mysqld_unix_port), |
| 8428 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | #else |
| 8429 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | "", |
| 8430 | #endif | ||
| 8431 | mysqld_port, MYSQL_COMPILATION_COMMENT_SERVER); | ||
| 8432 | |||
| 8433 | if (!opt_disable_networking && my_admin_bind_addr_str) | ||
| 8434 | LogEvent() | ||
| 8435 | .type(LOG_TYPE_ERROR) | ||
| 8436 | .subsys(LOG_SUBSYSTEM_TAG) | ||
| 8437 | .prio(SYSTEM_LEVEL) | ||
| 8438 | .lookup(ER_SERVER_STARTUP_ADMIN_INTERFACE, my_admin_bind_addr_str, | ||
| 8439 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | mysqld_admin_port, MYSQL_COMPILATION_COMMENT); |
| 8440 | |||
| 8441 | #if defined(_WIN32) | ||
| 8442 | if (windows_service) { | ||
| 8443 | Service_status_msg s("R"); | ||
| 8444 | send_service_status(s); | ||
| 8445 | 11401 | } | |
| 8446 | #endif | ||
| 8447 |
3/8✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11401 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 11401 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
11401 | |
| 8448 | server_components_initialized(); | ||
| 8449 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | |
| 8450 | /* | ||
| 8451 | 11401 | Set opt_super_readonly here because if opt_super_readonly is set | |
| 8452 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | in get_option, it will create problem while setting up event scheduler. |
| 8453 | */ | ||
| 8454 | set_super_read_only_post_init(); | ||
| 8455 |
4/6✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1514 times.
✓ Branch 3 taken 9887 times.
✓ Branch 4 taken 1514 times.
✗ Branch 5 not taken.
|
11401 | |
| 8456 | DBUG_PRINT("info", ("Block, listening for incoming connections")); | ||
| 8457 | |||
| 8458 | (void)MYSQL_SET_STAGE(0, __FILE__, __LINE__); | ||
| 8459 | |||
| 8460 | server_operational_state = SERVER_OPERATING; | ||
| 8461 | sysd::notify("READY=1\nSTATUS=Server is operational\nMAIN_PID=", getpid(), | ||
| 8462 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | "\n"); |
| 8463 | |||
| 8464 | 11401 | (void)RUN_HOOK(server_state, before_handle_connection, (nullptr)); | |
| 8465 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | |
| 8466 | #if defined(_WIN32) | ||
| 8467 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 11399 times.
|
11401 | if (mysqld_socket_acceptor != nullptr) |
| 8468 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 | mysqld_socket_acceptor->check_and_spawn_admin_connection_handler_thread(); |
| 8469 | setup_conn_event_handler_threads(); | ||
| 8470 | ✗ | #else | |
| 8471 | ✗ | mysql_mutex_lock(&LOCK_socket_listener_active); | |
| 8472 | ✗ | // Make it possible for the signal handler to kill the listener. | |
| 8473 | socket_listener_active = true; | ||
| 8474 | mysql_mutex_unlock(&LOCK_socket_listener_active); | ||
| 8475 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | |
| 8476 | if (opt_daemonize) { | ||
| 8477 | if (nstdout != nullptr) { | ||
| 8478 |
1/2✓ Branch 0 taken 11401 times.
✗ Branch 1 not taken.
|
11401 | // Show the pid on stdout if daemonizing and connected to tty |
| 8479 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
11401 | fprintf(nstdout, "mysqld is running as pid %lu\n", current_pid); |
| 8480 | fclose(nstdout); | ||
| 8481 | 9813 | nstdout = nullptr; | |
| 8482 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | } |
| 8483 | |||
| 8484 |
3/8✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9813 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
9813 | mysqld::runtime::signal_parent(pipe_write_fd, 1); |
| 8485 | } | ||
| 8486 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | |
| 8487 | mysqld_socket_acceptor->check_and_spawn_admin_connection_handler_thread(); | ||
| 8488 | mysqld_socket_acceptor->connection_event_loop(); | ||
| 8489 | #endif /* _WIN32 */ | ||
| 8490 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | server_operational_state = SERVER_SHUTTING_DOWN; |
| 8491 | sysd::notify("STOPPING=1\nSTATUS=Server shutdown in progress\n"); | ||
| 8492 | |||
| 8493 | DBUG_PRINT("info", ("No longer listening for incoming connections")); | ||
| 8494 | |||
| 8495 |
2/2✓ Branch 0 taken 9688 times.
✓ Branch 1 taken 125 times.
|
9813 | mysql_audit_notify(MYSQL_AUDIT_SERVER_SHUTDOWN_SHUTDOWN, |
| 8496 |
3/4✓ Branch 0 taken 9688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9685 times.
|
9688 | MYSQL_AUDIT_SERVER_SHUTDOWN_REASON_SHUTDOWN, |
| 8497 |
8/16✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 3 times.
✗ Branch 15 not taken.
|
3 | MYSQLD_SUCCESS_EXIT); |
| 8498 | |||
| 8499 | terminate_compress_gtid_table_thread(); | ||
| 8500 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | /* |
| 8501 | Save set of GTIDs of the last binlog into gtid_executed table | ||
| 8502 | 9813 | on server shutdown. | |
| 8503 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | */ |
| 8504 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | if (opt_bin_log) |
| 8505 | if (gtid_state->save_gtids_of_last_binlog_into_table()) | ||
| 8506 | LogErr(WARNING_LEVEL, ER_CANT_SAVE_GTIDS); | ||
| 8507 | |||
| 8508 | #ifndef _WIN32 | ||
| 8509 | mysql_mutex_lock(&LOCK_socket_listener_active); | ||
| 8510 | // Notify the signal handler that we have stopped listening for connections. | ||
| 8511 | socket_listener_active = false; | ||
| 8512 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | mysql_cond_broadcast(&COND_socket_listener_active); |
| 8513 | mysql_mutex_unlock(&LOCK_socket_listener_active); | ||
| 8514 | #endif // !_WIN32 | ||
| 8515 |
3/8✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9813 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 9813 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
9813 | |
| 8516 | 9813 | #ifdef HAVE_PSI_THREAD_INTERFACE | |
| 8517 | /* | ||
| 8518 | Disable the main thread instrumentation, | ||
| 8519 | to avoid recording events during the shutdown. | ||
| 8520 | */ | ||
| 8521 | PSI_THREAD_CALL(delete_current_thread)(); | ||
| 8522 | #endif /* HAVE_PSI_THREAD_INTERFACE */ | ||
| 8523 | |||
| 8524 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | DBUG_PRINT("info", ("Waiting for shutdown proceed")); |
| 8525 |
1/2✓ Branch 0 taken 9813 times.
✗ Branch 1 not taken.
|
9813 | int ret = 0; |
| 8526 | 9813 | #ifdef _WIN32 | |
| 8527 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9813 times.
|
9813 | if (shutdown_restart_thr_handle.handle) |
| 8528 | ✗ | ret = my_thread_join(&shutdown_restart_thr_handle, NULL); | |
| 8529 | shutdown_restart_thr_handle.handle = NULL; | ||
| 8530 | if (0 != ret) | ||
| 8531 |
1/2✓ Branch 0 taken 9795 times.
✗ Branch 1 not taken.
|
9813 | LogErr(WARNING_LEVEL, ER_CANT_JOIN_SHUTDOWN_THREAD, "shutdown ", ret); |
| 8532 | 9795 | #else | |
| 8533 | if (signal_thread_id.thread != 0) | ||
| 8534 | ret = my_thread_join(&signal_thread_id, nullptr); | ||
| 8535 | signal_thread_id.thread = 0; | ||
| 8536 | if (0 != ret) | ||
| 8537 | LogErr(WARNING_LEVEL, ER_CANT_JOIN_SHUTDOWN_THREAD, "signal_", ret); | ||
| 8538 | #endif // _WIN32 | ||
| 8539 | |||
| 8540 | clean_up(true); | ||
| 8541 | mysqld_exit(signal_hand_thr_exit_code); | ||
| 8542 | } | ||
| 8543 | |||
| 8544 | /**************************************************************************** | ||
| 8545 | Main and thread entry function for Win32 | ||
| 8546 | (all this is needed only to run mysqld as a service on WinNT) | ||
| 8547 | ****************************************************************************/ | ||
| 8548 | |||
| 8549 | #if defined(_WIN32) | ||
| 8550 | |||
| 8551 | bool is_windows_service() { return windows_service; } | ||
| 8552 | |||
| 8553 | NTService *get_win_service_ptr() { return &Service; } | ||
| 8554 | |||
| 8555 | int mysql_service(void *p) { | ||
| 8556 | int my_argc; | ||
| 8557 | char **my_argv; | ||
| 8558 | |||
| 8559 | if (use_opt_args) { | ||
| 8560 | my_argc = opt_argc; | ||
| 8561 | my_argv = opt_argv; | ||
| 8562 | } else if (is_mysqld_monitor()) { | ||
| 8563 | my_argc = Service.my_argc; | ||
| 8564 | my_argv = Service.my_argv; | ||
| 8565 | } else { | ||
| 8566 | my_argc = my_global_argc; | ||
| 8567 | my_argv = my_global_argv; | ||
| 8568 | } | ||
| 8569 | |||
| 8570 | if (!mysqld_early_option) { | ||
| 8571 | int res = start_monitor(); | ||
| 8572 | if (res != -1) { | ||
| 8573 | deinitialize_mysqld_monitor(); | ||
| 8574 | return res; | ||
| 8575 | } | ||
| 8576 | } | ||
| 8577 | |||
| 8578 | if (my_thread_init()) { | ||
| 8579 | flush_error_log_messages(); | ||
| 8580 | return 1; | ||
| 8581 | } | ||
| 8582 | |||
| 8583 | win_main(my_argc, my_argv); | ||
| 8584 | |||
| 8585 | my_thread_end(); | ||
| 8586 | return 0; | ||
| 8587 | } | ||
| 8588 | |||
| 8589 | /* Quote string if it contains space, else copy */ | ||
| 8590 | |||
| 8591 | static char *add_quoted_string(char *to, const char *from, char *to_end) { | ||
| 8592 | uint length = (uint)(to_end - to); | ||
| 8593 | |||
| 8594 | if (!strchr(from, ' ')) return strmake(to, from, length - 1); | ||
| 8595 | return strxnmov(to, length - 1, "\"", from, "\"", NullS); | ||
| 8596 | } | ||
| 8597 | |||
| 8598 | /** | ||
| 8599 | Handle basic handling of services, like installation and removal. | ||
| 8600 | |||
| 8601 | @param argv Pointer to argument list | ||
| 8602 | @param servicename Internal name of service | ||
| 8603 | @param displayname Display name of service (in taskbar ?) | ||
| 8604 | @param file_path Path to this program | ||
| 8605 | @param startup_option Startup option to mysqld | ||
| 8606 | |||
| 8607 | @retval | ||
| 8608 | 0 option handled | ||
| 8609 | @retval | ||
| 8610 | 1 Could not handle option | ||
| 8611 | */ | ||
| 8612 | |||
| 8613 | static bool default_service_handling(char **argv, const char *servicename, | ||
| 8614 | const char *displayname, | ||
| 8615 | const char *file_path, | ||
| 8616 | const char *extra_opt, | ||
| 8617 | const char *account_name) { | ||
| 8618 | char path_and_service[FN_REFLEN + FN_REFLEN + 32], *pos, *end; | ||
| 8619 | const char *opt_delim; | ||
| 8620 | end = path_and_service + sizeof(path_and_service) - 3; | ||
| 8621 | |||
| 8622 | /* We have to quote filename if it contains spaces */ | ||
| 8623 | pos = add_quoted_string(path_and_service, file_path, end); | ||
| 8624 | if (extra_opt && *extra_opt) { | ||
| 8625 | /* | ||
| 8626 | Add option after file_path. There will be zero or one extra option. It's | ||
| 8627 | assumed to be --defaults-file=file but isn't checked. The variable (not | ||
| 8628 | the option name) should be quoted if it contains a string. | ||
| 8629 | */ | ||
| 8630 | *pos++ = ' '; | ||
| 8631 | if (opt_delim = strchr(extra_opt, '=')) { | ||
| 8632 | size_t length = ++opt_delim - extra_opt; | ||
| 8633 | pos = my_stpnmov(pos, extra_opt, length); | ||
| 8634 | } else | ||
| 8635 | opt_delim = extra_opt; | ||
| 8636 | |||
| 8637 | pos = add_quoted_string(pos, opt_delim, end); | ||
| 8638 | } | ||
| 8639 | /* We must have servicename last */ | ||
| 8640 | *pos++ = ' '; | ||
| 8641 | (void)add_quoted_string(pos, servicename, end); | ||
| 8642 | |||
| 8643 | if (Service.got_service_option(argv, "install")) { | ||
| 8644 | Service.Install(1, servicename, displayname, path_and_service, | ||
| 8645 | account_name); | ||
| 8646 | return 0; | ||
| 8647 | } | ||
| 8648 | if (Service.got_service_option(argv, "install-manual")) { | ||
| 8649 | Service.Install(0, servicename, displayname, path_and_service, | ||
| 8650 | account_name); | ||
| 8651 | return 0; | ||
| 8652 | } | ||
| 8653 | if (Service.got_service_option(argv, "remove")) { | ||
| 8654 | Service.Remove(servicename); | ||
| 8655 | return 0; | ||
| 8656 | } | ||
| 8657 | return 1; | ||
| 8658 | } | ||
| 8659 | |||
| 8660 | int mysqld_main(int argc, char **argv) { | ||
| 8661 | bool mysqld_monitor = false; | ||
| 8662 | mysqld_early_option = is_early_option(argc, argv); | ||
| 8663 | |||
| 8664 | if (!mysqld_early_option) { | ||
| 8665 | initialize_mysqld_monitor(); | ||
| 8666 | mysqld_monitor = is_mysqld_monitor(); | ||
| 8667 | } | ||
| 8668 | |||
| 8669 | if (mysqld_early_option || !mysqld_monitor) { | ||
| 8670 | /* | ||
| 8671 | When several instances are running on the same machine, we | ||
| 8672 | need to have an unique named hEventShudown through the | ||
| 8673 | application PID e.g.: MySQLShutdown1890; MySQLShutdown2342 | ||
| 8674 | */ | ||
| 8675 | |||
| 8676 | longlong10_to_str(GetCurrentProcessId(), | ||
| 8677 | my_stpcpy(shutdown_event_name, "MYSQLShutdown"), 10); | ||
| 8678 | longlong10_to_str(GetCurrentProcessId(), | ||
| 8679 | my_stpcpy(restart_event_name, "MYSQLRestart"), 10); | ||
| 8680 | } | ||
| 8681 | |||
| 8682 | /* Must be initialized early for comparison of service name */ | ||
| 8683 | system_charset_info = &my_charset_utf8_general_ci; | ||
| 8684 | |||
| 8685 | if (mysqld_early_option || !mysqld_monitor) { | ||
| 8686 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 8687 | pre_initialize_performance_schema(); | ||
| 8688 | #endif /*WITH_PERFSCHEMA_STORAGE_ENGINE */ | ||
| 8689 | |||
| 8690 | if (my_init()) { | ||
| 8691 | LogErr(ERROR_LEVEL, ER_MYINIT_FAILED); | ||
| 8692 | flush_error_log_messages(); | ||
| 8693 | return 1; | ||
| 8694 | } | ||
| 8695 | } | ||
| 8696 | |||
| 8697 | if (mysqld_monitor) /* true NT family */ | ||
| 8698 | { | ||
| 8699 | char file_path[FN_REFLEN]; | ||
| 8700 | my_path(file_path, argv[0], ""); /* Find name in path */ | ||
| 8701 | fn_format(file_path, argv[0], file_path, "", | ||
| 8702 | MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_RESOLVE_SYMLINKS); | ||
| 8703 | |||
| 8704 | if (argc == 2) { | ||
| 8705 | if (!default_service_handling(argv, MYSQL_SERVICENAME, MYSQL_SERVICENAME, | ||
| 8706 | file_path, "", NULL)) | ||
| 8707 | return 0; | ||
| 8708 | if (Service.IsService(argv[1])) /* Start an optional service */ | ||
| 8709 | { | ||
| 8710 | /* | ||
| 8711 | Only add the service name to the groups read from the config file | ||
| 8712 | if it's not "MySQL". (The default service name should be 'mysqld' | ||
| 8713 | but we started a bad tradition by calling it MySQL from the start | ||
| 8714 | and we are now stuck with it. | ||
| 8715 | */ | ||
| 8716 | if (my_strcasecmp(system_charset_info, argv[1], "mysql")) | ||
| 8717 | load_default_groups[load_default_groups_sz - 2] = argv[1]; | ||
| 8718 | windows_service = true; | ||
| 8719 | |||
| 8720 | Service.Init(argv[1], mysql_service); | ||
| 8721 | return 0; | ||
| 8722 | } | ||
| 8723 | } else if (argc == 3) /* install or remove any optional service */ | ||
| 8724 | { | ||
| 8725 | if (!default_service_handling(argv, argv[2], argv[2], file_path, "", | ||
| 8726 | NULL)) | ||
| 8727 | return 0; | ||
| 8728 | if (Service.IsService(argv[2])) { | ||
| 8729 | /* | ||
| 8730 | mysqld was started as | ||
| 8731 | mysqld --defaults-file=my_path\my.ini service-name | ||
| 8732 | */ | ||
| 8733 | use_opt_args = 1; | ||
| 8734 | opt_argc = 2; // Skip service-name | ||
| 8735 | opt_argv = argv; | ||
| 8736 | windows_service = true; | ||
| 8737 | if (my_strcasecmp(system_charset_info, argv[2], "mysql")) | ||
| 8738 | load_default_groups[load_default_groups_sz - 2] = argv[2]; | ||
| 8739 | Service.Init(argv[2], mysql_service); | ||
| 8740 | return 0; | ||
| 8741 | } | ||
| 8742 | } else if (argc == 4 || argc == 5) { | ||
| 8743 | /* | ||
| 8744 | This may seem strange, because we handle --local-service while | ||
| 8745 | preserving 4.1's behavior of allowing any one other argument that is | ||
| 8746 | passed to the service on startup. (The assumption is that this is | ||
| 8747 | --defaults-file=file, but that was not enforced in 4.1, so we don't | ||
| 8748 | enforce it here.) | ||
| 8749 | */ | ||
| 8750 | const char *extra_opt = NullS; | ||
| 8751 | const char *account_name = NullS; | ||
| 8752 | int index; | ||
| 8753 | for (index = 3; index < argc; index++) { | ||
| 8754 | if (!strcmp(argv[index], "--local-service")) | ||
| 8755 | account_name = "NT AUTHORITY\\LocalService"; | ||
| 8756 | else | ||
| 8757 | extra_opt = argv[index]; | ||
| 8758 | } | ||
| 8759 | |||
| 8760 | if (argc == 4 || account_name) | ||
| 8761 | if (!default_service_handling(argv, argv[2], argv[2], file_path, | ||
| 8762 | extra_opt, account_name)) | ||
| 8763 | return 0; | ||
| 8764 | } else if (argc == 1 && Service.IsService(MYSQL_SERVICENAME)) { | ||
| 8765 | /* start the default service */ | ||
| 8766 | windows_service = true; | ||
| 8767 | Service.Init(MYSQL_SERVICENAME, mysql_service); | ||
| 8768 | return 0; | ||
| 8769 | } | ||
| 8770 | } | ||
| 8771 | |||
| 8772 | // Set windows_service value in mysqld | ||
| 8773 | if (!mysqld_monitor) { | ||
| 8774 | windows_service = is_monitor_win_service(); | ||
| 8775 | |||
| 8776 | if (windows_service) { | ||
| 8777 | if (argc == 2 && Service.IsService(argv[1])) { | ||
| 8778 | if (my_strcasecmp(system_charset_info, argv[1], "mysql")) | ||
| 8779 | load_default_groups[load_default_groups_sz - 2] = argv[1]; | ||
| 8780 | argc--; | ||
| 8781 | |||
| 8782 | } else if (argc == 3 && Service.IsService(argv[2])) { | ||
| 8783 | /* | ||
| 8784 | mysqld was started as | ||
| 8785 | mysqld --defaults-file=my_path\my.ini service-name | ||
| 8786 | */ | ||
| 8787 | if (my_strcasecmp(system_charset_info, argv[2], "mysql")) | ||
| 8788 | load_default_groups[load_default_groups_sz - 2] = argv[2]; | ||
| 8789 | argc--; | ||
| 8790 | } | ||
| 8791 | } | ||
| 8792 | |||
| 8793 | my_global_argc = argc; | ||
| 8794 | my_global_argv = argv; | ||
| 8795 | } else { | ||
| 8796 | Service.my_argc = argc; | ||
| 8797 | Service.my_argv = argv; | ||
| 8798 | } | ||
| 8799 | |||
| 8800 | return mysql_service(NULL); | ||
| 8801 | } | ||
| 8802 | #endif // _WIN32 | ||
| 8803 | |||
| 8804 | /** | ||
| 8805 | Execute the bootstrap thread, if required. | ||
| 8806 | |||
| 8807 | When mysqld is started with --initialize only, | ||
| 8808 | the bootstrap thread executes | ||
| 8809 | - compiled in statements. | ||
| 8810 | - create the non-DD based INFORMATION_SCHEMA. | ||
| 8811 | and the server exits. | ||
| 8812 | |||
| 8813 | When mysqld is started with --init-file only, | ||
| 8814 | the bootstrap thread executes SQL statements provided | ||
| 8815 | in the input text file, | ||
| 8816 | and the server continues and serves requests. | ||
| 8817 | |||
| 8818 | When mysqld is started with both --initialize and --init-file, | ||
| 8819 | the bootstrap thread: | ||
| 8820 | - executes compiled in statements, | ||
| 8821 | 11691 | - executes SQL statements in the --init-file. | |
| 8822 | 11691 | - creates the non-DD based INFORMATION_SCHEMA. | |
| 8823 | 11691 | The server then exits. | |
| 8824 | |||
| 8825 | 11691 | Compiled in statements are executed in a privileged mode, | |
| 8826 | with SYSTEM_THREAD_SERVER_INITIALIZE. | ||
| 8827 |
2/2✓ Branch 0 taken 286 times.
✓ Branch 1 taken 11405 times.
|
11691 | |
| 8828 | @see handle_bootstrap_impl | ||
| 8829 | 286 | */ | |
| 8830 | 286 | static void process_bootstrap() { | |
| 8831 | 286 | MYSQL_FILE *init_file = nullptr; | |
| 8832 | const char *init_file_name = nullptr; | ||
| 8833 | 11405 | enum_thread_type system_thread; | |
| 8834 | bool need_bootstrap = false; | ||
| 8835 | |||
| 8836 |
2/2✓ Branch 0 taken 275 times.
✓ Branch 1 taken 11416 times.
|
11691 | if (opt_initialize) { |
| 8837 |
2/2✓ Branch 0 taken 274 times.
✓ Branch 1 taken 1 times.
|
275 | // Make sure we can process SIGHUP during bootstrap. |
| 8838 | 274 | server_components_initialized(); | |
| 8839 |
7/14✓ Branch 0 taken 274 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 274 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 274 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 274 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 274 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 274 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 274 times.
✗ Branch 13 not taken.
|
274 | need_bootstrap = true; |
| 8840 | system_thread = SYSTEM_THREAD_SERVER_INITIALIZE; | ||
| 8841 | 274 | } else { | |
| 8842 | system_thread = SYSTEM_THREAD_INIT_FILE; | ||
| 8843 | 274 | } | |
| 8844 | |||
| 8845 | if (opt_init_file != nullptr) { | ||
| 8846 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 273 times.
|
275 | if (*opt_init_file != '\0') { |
| 8847 |
7/14✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
|
2 | init_file_name = opt_init_file; |
| 8848 | 2 | LogErr(INFORMATION_LEVEL, ER_BEG_INITFILE, init_file_name); | |
| 8849 | |||
| 8850 | init_file = mysql_file_fopen(key_file_init, init_file_name, O_RDONLY, | ||
| 8851 | MYF(MY_WME)); | ||
| 8852 |
2/2✓ Branch 0 taken 306 times.
✓ Branch 1 taken 11383 times.
|
11689 | need_bootstrap = true; |
| 8853 | 306 | } | |
| 8854 | |||
| 8855 | if (init_file == nullptr) { | ||
| 8856 |
2/2✓ Branch 0 taken 273 times.
✓ Branch 1 taken 33 times.
|
306 | LogErr(ERROR_LEVEL, ER_INIT_CANT_OPEN_BOOTSTRAP_FILE, init_file_name); |
| 8857 | 273 | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 8858 |
7/14✓ Branch 0 taken 273 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 273 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 273 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 273 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 273 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 273 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 273 times.
✗ Branch 13 not taken.
|
273 | } |
| 8859 | } | ||
| 8860 | |||
| 8861 |
2/2✓ Branch 0 taken 11 times.
✓ Branch 1 taken 295 times.
|
306 | if (need_bootstrap) { |
| 8862 | bool error = bootstrap::run_bootstrap_thread(init_file_name, init_file, | ||
| 8863 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 7 times.
|
11 | nullptr, system_thread); |
| 8864 | 4 | ||
| 8865 | if (init_file != nullptr) { | ||
| 8866 | mysql_file_fclose(init_file, MYF(MY_WME)); | ||
| 8867 | LogErr(INFORMATION_LEVEL, ER_END_INITFILE, init_file_name); | ||
| 8868 |
2/2✓ Branch 0 taken 280 times.
✓ Branch 1 taken 22 times.
|
302 | } |
| 8869 | |||
| 8870 | 280 | if (error) { | |
| 8871 | /* Abort during system initialization, but not init-file execution */ | ||
| 8872 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
|
280 | if (system_thread == SYSTEM_THREAD_SERVER_INITIALIZE) { |
| 8873 | ✗ | unireg_abort(MYSQLD_ABORT_EXIT); | |
| 8874 | ✗ | } | |
| 8875 | } | ||
| 8876 | |||
| 8877 | 280 | if (opt_initialize) { | |
| 8878 | // Create non DD based system views during --initialize. | ||
| 8879 | error = dd::init( | ||
| 8880 | dd::enum_dd_init_type::DD_INITIALIZE_NON_DD_BASED_SYSTEM_VIEWS); | ||
| 8881 | 11405 | if (error != 0) { | |
| 8882 | LogErr(ERROR_LEVEL, ER_SYSTEM_VIEW_INIT_FAILED); | ||
| 8883 | unireg_abort(MYSQLD_ABORT_EXIT); | ||
| 8884 | } | ||
| 8885 | |||
| 8886 | unireg_abort(MYSQLD_SUCCESS_EXIT); | ||
| 8887 | } | ||
| 8888 | } | ||
| 8889 | |||
| 8890 | return; | ||
| 8891 | } | ||
| 8892 | |||
| 8893 | 12109 | /**************************************************************************** | |
| 8894 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12109 times.
|
12109 | Handle start options |
| 8895 | ******************************************************************************/ | ||
| 8896 | |||
| 8897 | 12109 | /** | |
| 8898 | 12109 | Process command line options but use only "help", "initialize", | |
| 8899 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | "initialize-insecure". If one of these options exists then change default |
| 8900 |
3/4✓ Branch 0 taken 914800 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 914800 times.
✓ Branch 3 taken 12109 times.
|
926909 | value of log_error_verbosity. |
| 8901 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | */ |
| 8902 | static void adjust_log_error_verbosity(vector<my_option> *all_early_options) { | ||
| 8903 | if (remaining_argc <= 1) return; | ||
| 8904 | 12109 | ||
| 8905 | /* create a copy of remaining_argv */ | ||
| 8906 |
3/8✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12109 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12109 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
12109 | int copy_argc = remaining_argc; |
| 8907 |
2/2✓ Branch 0 taken 254289 times.
✓ Branch 1 taken 12109 times.
|
266398 | vector<char *> copy_argv; |
| 8908 |
1/2✓ Branch 0 taken 254289 times.
✗ Branch 1 not taken.
|
254289 | copy_argv.reserve(copy_argc + 1); |
| 8909 |
2/2✓ Branch 0 taken 36327 times.
✓ Branch 1 taken 217962 times.
|
508578 | for (int i = 0; i < copy_argc; i++) copy_argv.push_back(remaining_argv[i]); |
| 8910 |
1/2✓ Branch 0 taken 36327 times.
✗ Branch 1 not taken.
|
36327 | copy_argv.push_back(nullptr); |
| 8911 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 8912 | /* select only "help", "initialize", "initialize-insecure" options */ | ||
| 8913 | 12109 | vector<my_option> init_options; | |
| 8914 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | static const vector<const char *> opt_names{"help", "initialize", |
| 8915 | "initialize-insecure"}; | ||
| 8916 | for (my_option *opt = my_long_early_options; opt->name != nullptr; opt++) | ||
| 8917 |
3/4✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12095 times.
✓ Branch 3 taken 14 times.
|
12109 | if (std::find(opt_names.cbegin(), opt_names.cend(), opt->name) != |
| 8918 |
4/4✓ Branch 0 taken 12079 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 284 times.
✓ Branch 3 taken 11795 times.
|
12095 | opt_names.cend()) |
| 8919 | init_options.push_back(*opt); | ||
| 8920 | add_terminator(&init_options); | ||
| 8921 | |||
| 8922 | char **copy_argv_ptr = ©_argv[0]; | ||
| 8923 | int ho_error = handle_options(©_argc, ©_argv_ptr, &init_options[0], | ||
| 8924 | mysqld_get_one_option); | ||
| 8925 | |||
| 8926 |
2/2✓ Branch 0 taken 30458 times.
✓ Branch 1 taken 314 times.
|
30772 | if ((ho_error == 0) && |
| 8927 |
2/2✓ Branch 0 taken 314 times.
✓ Branch 1 taken 30144 times.
|
30458 | (opt_help || opt_initialize || opt_initialize_insecure)) { |
| 8928 |
4/4✓ Branch 0 taken 298 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 13 times.
|
314 | /* |
| 8929 | Show errors during --help, but mute everything else so the info the | ||
| 8930 | user actually wants isn't lost in the spam. (For --help --verbose, | ||
| 8931 | 12109 | we need to set up far enough to be able to print variables provided | |
| 8932 | by plugins, so a good number of warnings/notes might get printed.) | ||
| 8933 | Likewise for --initialize. | ||
| 8934 | */ | ||
| 8935 | for (my_option *opt = &(*all_early_options)[0]; opt->name; opt++) | ||
| 8936 | if (!strcmp("log_error_verbosity", opt->name)) { | ||
| 8937 | opt->def_value = (opt_initialize || opt_initialize_insecure) ? 2 : 1; | ||
| 8938 | } | ||
| 8939 | } | ||
| 8940 | } | ||
| 8941 | |||
| 8942 | /** | ||
| 8943 | Process command line options flagged as 'early'. | ||
| 8944 | 12109 | Some components needs to be initialized as early as possible, | |
| 8945 | because the rest of the server initialization depends on them. | ||
| 8946 | 12109 | Options that needs to be parsed early includes: | |
| 8947 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | - the performance schema, when compiled in, |
| 8948 | - options related to the help, | ||
| 8949 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | - options related to the bootstrap |
| 8950 | The performance schema needs to be initialized as early as possible, | ||
| 8951 | 12109 | before to-be-instrumented objects of the server are initialized. | |
| 8952 | */ | ||
| 8953 | static int handle_early_options() { | ||
| 8954 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | int ho_error; |
| 8955 | vector<my_option> all_early_options; | ||
| 8956 | all_early_options.reserve(100); | ||
| 8957 |
2/2✓ Branch 0 taken 254289 times.
✓ Branch 1 taken 12109 times.
|
266398 | |
| 8958 |
1/2✓ Branch 0 taken 254289 times.
✗ Branch 1 not taken.
|
254289 | my_getopt_register_get_addr(nullptr); |
| 8959 | /* Skip unknown options so that they may be processed later */ | ||
| 8960 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | my_getopt_skip_unknown = true; |
| 8961 | |||
| 8962 | 12109 | /* Add the system variables parsed early */ | |
| 8963 | 12109 | sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY); | |
| 8964 | |||
| 8965 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | /* Add the command line options parsed early */ |
| 8966 | for (my_option *opt = my_long_early_options; opt->name != nullptr; opt++) | ||
| 8967 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | all_early_options.push_back(*opt); |
| 8968 | 12109 | ||
| 8969 | add_terminator(&all_early_options); | ||
| 8970 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | |
| 8971 | my_getopt_error_reporter = option_error_reporter; | ||
| 8972 |
1/2✓ Branch 0 taken 12109 times.
✗ Branch 1 not taken.
|
12109 | my_charset_error_reporter = charset_error_reporter; |
| 8973 | |||
| 8974 | adjust_log_error_verbosity(&all_early_options); | ||
| 8975 | 12109 | ||
| 8976 | 12109 | ho_error = handle_options(&remaining_argc, &remaining_argv, | |
| 8977 | &all_early_options[0], mysqld_get_one_option); | ||
| 8978 |
2/2✓ Branch 0 taken 285 times.
✓ Branch 1 taken 11824 times.
|
12109 | |
| 8979 | if (ho_error == 0) { | ||
| 8980 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 12107 times.
|
12109 | /* update verbosity in filter engine, if needed */ |
| 8981 | log_builtins_filter_update_verbosity(log_error_verbosity); | ||
| 8982 | 2 | ||
| 8983 | 2 | /* Add back the program name handle_options removes */ | |
| 8984 | remaining_argc++; | ||
| 8985 | remaining_argv--; | ||
| 8986 | |||
| 8987 | if (opt_initialize_insecure) opt_initialize = true; | ||
| 8988 | 12109 | ||
| 8989 | if (opt_debugging) { | ||
| 8990 | 12109 | /* Allow break with SIGINT, no core or stack trace */ | |
| 8991 | 12109 | test_flags |= TEST_SIGINT | TEST_NO_STACKTRACE; | |
| 8992 | test_flags &= ~TEST_CORE_ON_SIGNAL; | ||
| 8993 | } | ||
| 8994 | } | ||
| 8995 | |||
| 8996 | // Swap with an empty vector, i.e. delete elements and free allocated space. | ||
| 8997 | vector<my_option>().swap(all_early_options); | ||
| 8998 | |||
| 8999 | return ho_error; | ||
| 9000 | 12104 | } | |
| 9001 | |||
| 9002 | /** | ||
| 9003 | Adjust @c open_files_limit. | ||
| 9004 | Computation is based on: | ||
| 9005 | - @c max_connections, | ||
| 9006 | - @c table_cache_size, | ||
| 9007 | - the platform max open file limit. | ||
| 9008 | 12104 | */ | |
| 9009 | static void adjust_open_files_limit(ulong *requested_open_files) { | ||
| 9010 | ulong limit_1; | ||
| 9011 | ulong limit_2; | ||
| 9012 | ulong limit_3; | ||
| 9013 | ulong request_open_files; | ||
| 9014 | ulong effective_open_files; | ||
| 9015 | 12104 | ||
| 9016 | /* MyISAM requires two file handles per table. */ | ||
| 9017 | limit_1 = 10 + max_connections + table_cache_size * 2; | ||
| 9018 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12101 times.
|
12104 | |
| 9019 | /* | ||
| 9020 | 12104 | We are trying to allocate no less than max_connections*5 file | |
| 9021 | handles (i.e. we are trying to set the limit so that they will | ||
| 9022 | be available). | ||
| 9023 |
1/2✓ Branch 0 taken 12104 times.
✗ Branch 1 not taken.
|
12104 | */ |
| 9024 | limit_2 = max_connections * 5; | ||
| 9025 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12104 times.
|
12104 | |
| 9026 | ✗ | /* Try to allocate no less than 5000 by default. */ | |
| 9027 | ✗ | limit_3 = open_files_limit ? open_files_limit : 5000; | |
| 9028 | |||
| 9029 | request_open_files = max<ulong>(max<ulong>(limit_1, limit_2), limit_3); | ||
| 9030 | ✗ | ||
| 9031 | /* Notice: my_set_max_open_files() may return more than requested. */ | ||
| 9032 | effective_open_files = my_set_max_open_files(request_open_files); | ||
| 9033 | |||
| 9034 | if (effective_open_files < request_open_files) { | ||
| 9035 | 12104 | if (open_files_limit == 0) { | |
| 9036 |
1/2✓ Branch 0 taken 12104 times.
✗ Branch 1 not taken.
|
12104 | LogErr(WARNING_LEVEL, ER_CHANGED_MAX_OPEN_FILES, effective_open_files, |
| 9037 | 12104 | request_open_files); | |
| 9038 | 12104 | } else { | |
| 9039 | 12104 | LogErr(WARNING_LEVEL, ER_CANT_INCREASE_MAX_OPEN_FILES, | |
| 9040 | effective_open_files, request_open_files); | ||
| 9041 | } | ||
| 9042 | } | ||
| 9043 | 12104 | ||
| 9044 | open_files_limit = effective_open_files; | ||
| 9045 | if (requested_open_files) | ||
| 9046 | 12104 | *requested_open_files = | |
| 9047 | min<ulong>(effective_open_files, request_open_files); | ||
| 9048 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12104 times.
|
12104 | } |
| 9049 | ✗ | ||
| 9050 | static constexpr const ulong TABLE_OPEN_CACHE_MIN{400}; | ||
| 9051 | |||
| 9052 | ✗ | static void adjust_max_connections(ulong requested_open_files) { | |
| 9053 | ulong limit; | ||
| 9054 | 12104 | ||
| 9055 | limit = requested_open_files - 10 - TABLE_OPEN_CACHE_MIN * 2; | ||
| 9056 | 12104 | ||
| 9057 | if (limit < max_connections) { | ||
| 9058 | LogErr(WARNING_LEVEL, ER_CHANGED_MAX_CONNECTIONS, limit, max_connections); | ||
| 9059 | 12104 | ||
| 9060 | // This can be done unprotected since it is only called on startup. | ||
| 9061 | max_connections = limit; | ||
| 9062 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12104 times.
|
12104 | } |
| 9063 | ✗ | } | |
| 9064 | |||
| 9065 | ✗ | static void adjust_table_cache_size(ulong requested_open_files) { | |
| 9066 | ulong limit; | ||
| 9067 | |||
| 9068 | 12104 | limit = max<ulong>((requested_open_files - 10 - max_connections) / 2, | |
| 9069 | 12104 | TABLE_OPEN_CACHE_MIN); | |
| 9070 | |||
| 9071 | 12104 | if (limit < table_cache_size) { | |
| 9072 | LogErr(WARNING_LEVEL, ER_CHANGED_TABLE_OPEN_CACHE, limit, table_cache_size); | ||
| 9073 | |||
| 9074 | table_cache_size = limit; | ||
| 9075 | 12104 | } | |
| 9076 |
2/4✓ Branch 0 taken 12104 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12104 times.
✗ Branch 3 not taken.
|
12104 | |
| 9077 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12104 times.
|
12104 | table_cache_size_per_instance = table_cache_size / table_cache_instances; |
| 9078 | 12104 | } | |
| 9079 | |||
| 9080 |
2/2✓ Branch 0 taken 12102 times.
✓ Branch 1 taken 2 times.
|
12104 | static void adjust_table_def_size() { |
| 9081 | 12104 | ulong default_value; | |
| 9082 | sys_var *var; | ||
| 9083 | 12104 | ||
| 9084 | default_value = min<ulong>(400 + table_cache_size / 2, 2000); | ||
| 9085 | var = find_static_system_variable("table_definition_cache"); | ||
| 9086 | assert(var != nullptr); | ||
| 9087 |
2/2✓ Branch 0 taken 301 times.
✓ Branch 1 taken 11803 times.
|
12104 | var->update_default(default_value); |
| 9088 | |||
| 9089 | if (!table_definition_cache_specified) table_def_size = default_value; | ||
| 9090 | 12104 | } | |
| 9091 | 12104 | ||
| 9092 | 12104 | static void adjust_related_options(ulong *requested_open_files) { | |
| 9093 | 12104 | /* | |
| 9094 | 12104 | In bootstrap, disable grant tables (about to be created) | |
| 9095 | */ | ||
| 9096 | if (opt_initialize) opt_noacl = true; | ||
| 9097 | |||
| 9098 | /* The order is critical here, because of dependencies. */ | ||
| 9099 | adjust_open_files_limit(requested_open_files); | ||
| 9100 | adjust_max_connections(*requested_open_files); | ||
| 9101 | adjust_table_cache_size(*requested_open_files); | ||
| 9102 | adjust_table_def_size(); | ||
| 9103 | } | ||
| 9104 | |||
| 9105 | vector<my_option> all_options; | ||
| 9106 | |||
| 9107 | struct my_option my_long_early_options[] = { | ||
| 9108 | #if !defined(_WIN32) | ||
| 9109 | {"daemonize", 'D', "Run mysqld as sysv daemon", &opt_daemonize, | ||
| 9110 | &opt_daemonize, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9111 | #endif | ||
| 9112 | {"skip-grant-tables", 0, | ||
| 9113 | "Start without grant tables. This gives all users FULL ACCESS to all " | ||
| 9114 | "tables.", | ||
| 9115 | &opt_noacl, &opt_noacl, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, | ||
| 9116 | nullptr}, | ||
| 9117 | {"help", '?', "Display this help and exit.", &opt_help, &opt_help, nullptr, | ||
| 9118 | GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9119 | {"verbose", 'v', "Used with --help option for detailed help.", &opt_verbose, | ||
| 9120 | &opt_verbose, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9121 | {"version", 'V', "Output version information and exit.", nullptr, nullptr, | ||
| 9122 | nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9123 | {"initialize", 'I', | ||
| 9124 | "Create the default database and exit." | ||
| 9125 | " Create a super user with a random expired password and store it into " | ||
| 9126 | "the log.", | ||
| 9127 | &opt_initialize, &opt_initialize, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, | ||
| 9128 | nullptr, 0, nullptr}, | ||
| 9129 | {"initialize-insecure", 0, | ||
| 9130 | "Create the default database and exit." | ||
| 9131 | " Create a super user with empty password.", | ||
| 9132 | &opt_initialize_insecure, &opt_initialize_insecure, nullptr, GET_BOOL, | ||
| 9133 | NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9134 | {"keyring-migration-source", OPT_KEYRING_MIGRATION_SOURCE, | ||
| 9135 | "Keyring plugin from where the keys needs to " | ||
| 9136 | "be migrated to. This option must be specified along with " | ||
| 9137 | "--keyring-migration-destination.", | ||
| 9138 | &opt_keyring_migration_source, &opt_keyring_migration_source, nullptr, | ||
| 9139 | GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9140 | {"keyring-migration-destination", OPT_KEYRING_MIGRATION_DESTINATION, | ||
| 9141 | "Keyring plugin or component to which the keys are migrated to.", | ||
| 9142 | &opt_keyring_migration_destination, &opt_keyring_migration_destination, | ||
| 9143 | nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9144 | {"keyring-migration-user", OPT_KEYRING_MIGRATION_USER, | ||
| 9145 | "User to login to server.", &opt_keyring_migration_user, | ||
| 9146 | &opt_keyring_migration_user, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, | ||
| 9147 | nullptr, 0, nullptr}, | ||
| 9148 | {"keyring-migration-host", OPT_KEYRING_MIGRATION_HOST, "Connect to host.", | ||
| 9149 | &opt_keyring_migration_host, &opt_keyring_migration_host, nullptr, GET_STR, | ||
| 9150 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9151 | {"keyring-migration-password", 'p', | ||
| 9152 | "Password to use when connecting to server during keyring migration. " | ||
| 9153 | "If password value is not specified then it will be asked from the tty.", | ||
| 9154 | nullptr, nullptr, nullptr, GET_PASSWORD, OPT_ARG, 0, 0, 0, nullptr, 0, | ||
| 9155 | nullptr}, | ||
| 9156 | {"keyring-migration-socket", OPT_KEYRING_MIGRATION_SOCKET, | ||
| 9157 | "The socket file to use for connection.", &opt_keyring_migration_socket, | ||
| 9158 | &opt_keyring_migration_socket, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, | ||
| 9159 | nullptr, 0, nullptr}, | ||
| 9160 | {"keyring-migration-port", OPT_KEYRING_MIGRATION_PORT, | ||
| 9161 | "Port number to use for connection.", &opt_keyring_migration_port, | ||
| 9162 | &opt_keyring_migration_port, nullptr, GET_ULONG, REQUIRED_ARG, 0, 0, 0, | ||
| 9163 | nullptr, 0, nullptr}, | ||
| 9164 | {"keyring-migration-to-component", OPT_KEYRING_MIGRATION_TO_COMPONENT, | ||
| 9165 | "Migrate from keyring plugin to keyring component.", | ||
| 9166 | &opt_keyring_migration_to_component, &opt_keyring_migration_to_component, | ||
| 9167 | nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9168 | {"no-dd-upgrade", 0, | ||
| 9169 | "Abort restart if automatic upgrade or downgrade of the data dictionary " | ||
| 9170 | "is needed. Deprecated option. Use --upgrade=NONE instead.", | ||
| 9171 | &opt_no_dd_upgrade, &opt_no_dd_upgrade, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, | ||
| 9172 | nullptr, 0, nullptr}, | ||
| 9173 | {"validate-config", 0, | ||
| 9174 | "Validate the server configuration specified by the user.", | ||
| 9175 | &opt_validate_config, &opt_validate_config, nullptr, GET_BOOL, NO_ARG, 0, | ||
| 9176 | 0, 0, nullptr, 0, nullptr}, | ||
| 9177 | {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, nullptr, | ||
| 9178 | GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9179 | {"coredumper", OPT_COREDUMPER, | ||
| 9180 | "Use coredumper library to generate coredumps. Specify a path for " | ||
| 9181 | "coredump " | ||
| 9182 | "otherwise it will be generated on datadir", | ||
| 9183 | &opt_libcoredumper_path, &opt_libcoredumper_path, 0, GET_STR, OPT_ARG, 0, | ||
| 9184 | 0, 0, 0, 0, 0}, | ||
| 9185 | {"skip-stack-trace", OPT_SKIP_STACK_TRACE, | ||
| 9186 | "Don't print a stack trace on failure.", 0, 0, nullptr, GET_NO_ARG, NO_ARG, | ||
| 9187 | 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9188 | /* We must always support the next option to make scripts like mysqltest | ||
| 9189 | easier to do */ | ||
| 9190 | {"gdb", 0, "Set up signals usable for debugging.", &opt_debugging, | ||
| 9191 | &opt_debugging, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9192 | {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, | ||
| 9193 | 0, nullptr, 0, nullptr}}; | ||
| 9194 | |||
| 9195 | /** | ||
| 9196 | System variables are automatically command-line options (few | ||
| 9197 | exceptions are documented in sys_var.h), so don't need | ||
| 9198 | to be listed here. | ||
| 9199 | */ | ||
| 9200 | |||
| 9201 | struct my_option my_long_options[] = { | ||
| 9202 | {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT, | ||
| 9203 | "Option used by mysql-test for debugging and testing of replication." | ||
| 9204 | "This option is deprecated and will be removed in a future version. ", | ||
| 9205 | &abort_slave_event_count, &abort_slave_event_count, nullptr, GET_INT, | ||
| 9206 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9207 | {"allow-suspicious-udfs", 0, | ||
| 9208 | "Allows use of UDFs consisting of only one symbol xxx() " | ||
| 9209 | "without corresponding xxx_init() or xxx_deinit(). That also means " | ||
| 9210 | "that one can load any function from any library, for example exit() " | ||
| 9211 | "from libc.so", | ||
| 9212 | &opt_allow_suspicious_udfs, &opt_allow_suspicious_udfs, nullptr, GET_BOOL, | ||
| 9213 | NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9214 | {"ansi", 'a', | ||
| 9215 | "Use ANSI SQL syntax instead of MySQL syntax. This mode " | ||
| 9216 | "will also set transaction isolation level 'serializable'.", | ||
| 9217 | nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, | ||
| 9218 | nullptr}, | ||
| 9219 | /* | ||
| 9220 | Because Sys_var_bit does not support command-line options, we need to | ||
| 9221 | explicitly add one for --autocommit | ||
| 9222 | */ | ||
| 9223 | {"autocommit", 0, "Set default value for autocommit (0 or 1)", | ||
| 9224 | &opt_autocommit, &opt_autocommit, nullptr, GET_BOOL, OPT_ARG, 1, 0, 0, | ||
| 9225 | &source_autocommit, /* arg_source, to be copied to Sys_var */ | ||
| 9226 | 0, nullptr}, | ||
| 9227 | {"binlog-do-db", OPT_BINLOG_DO_DB, | ||
| 9228 | "Include only updates to the specified database when writing the " | ||
| 9229 | "binary log.", | ||
| 9230 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9231 | nullptr}, | ||
| 9232 | {"binlog-ignore-db", OPT_BINLOG_IGNORE_DB, | ||
| 9233 | "Exclude updates to the specified database when writing the binary " | ||
| 9234 | "log.", | ||
| 9235 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9236 | nullptr}, | ||
| 9237 | {"character-set-client-handshake", 0, | ||
| 9238 | "Don't ignore client side character set value sent during handshake.", | ||
| 9239 | &opt_character_set_client_handshake, &opt_character_set_client_handshake, | ||
| 9240 | nullptr, GET_BOOL, NO_ARG, 1, 0, 0, nullptr, 0, nullptr}, | ||
| 9241 | {"character-set-filesystem", 0, "Set the filesystem character set.", | ||
| 9242 | &character_set_filesystem_name, &character_set_filesystem_name, nullptr, | ||
| 9243 | GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9244 | {"character-set-server", 'C', "Set the default character set.", | ||
| 9245 | &default_character_set_name, &default_character_set_name, nullptr, GET_STR, | ||
| 9246 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9247 | {"chroot", 'r', "Chroot mysqld daemon during startup.", &mysqld_chroot, | ||
| 9248 | &mysqld_chroot, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9249 | nullptr}, | ||
| 9250 | {"collation-server", 0, "Set the default collation.", | ||
| 9251 | &default_collation_name, &default_collation_name, nullptr, GET_STR, | ||
| 9252 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9253 | {"console", OPT_CONSOLE, | ||
| 9254 | "Write error output on screen; don't remove the console window on " | ||
| 9255 | "windows.", | ||
| 9256 | &opt_console, &opt_console, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, | ||
| 9257 | nullptr}, | ||
| 9258 | /* default-storage-engine should have "MyISAM" as def_value. Instead | ||
| 9259 | of initializing it here it is done in init_common_variables() due | ||
| 9260 | to a compiler bug in Sun Studio compiler. */ | ||
| 9261 | {"default-storage-engine", 0, "The default storage engine for new tables", | ||
| 9262 | &default_storage_engine, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, | ||
| 9263 | nullptr, 0, nullptr}, | ||
| 9264 | {"default-tmp-storage-engine", 0, | ||
| 9265 | "The default storage engine for new explicit temporary tables", | ||
| 9266 | &default_tmp_storage_engine, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, | ||
| 9267 | 0, nullptr, 0, nullptr}, | ||
| 9268 | {"default-time-zone", 0, "Set the default time zone.", &default_tz_name, | ||
| 9269 | &default_tz_name, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9270 | nullptr}, | ||
| 9271 | {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT, | ||
| 9272 | "Option used by mysql-test for debugging and testing of replication." | ||
| 9273 | "This option is deprecated and will be removed in a future version.", | ||
| 9274 | &disconnect_slave_event_count, &disconnect_slave_event_count, nullptr, | ||
| 9275 | GET_INT, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9276 | {"exit-info", 'T', "Used for debugging. Use at your own risk.", nullptr, | ||
| 9277 | nullptr, nullptr, GET_LONG, OPT_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9278 | |||
| 9279 | {"external-locking", 0, | ||
| 9280 | "Use system (external) locking (disabled by " | ||
| 9281 | "default). With this option enabled you can run myisamchk to test " | ||
| 9282 | "(not repair) tables while the MySQL server is running. Disable with " | ||
| 9283 | "--skip-external-locking.", | ||
| 9284 | &opt_external_locking, &opt_external_locking, nullptr, GET_BOOL, NO_ARG, 0, | ||
| 9285 | 0, 0, nullptr, 0, nullptr}, | ||
| 9286 | #if defined(HAVE_LINUX_LARGE_PAGES) || defined(HAVE_SOLARIS_LARGE_PAGES) | ||
| 9287 | {"super-large-pages", 0, "Enable support for super large pages.", | ||
| 9288 | &opt_super_large_pages, &opt_super_large_pages, nullptr, GET_BOOL, OPT_ARG, | ||
| 9289 | 0, 0, 1, nullptr, 1, nullptr}, | ||
| 9290 | #endif | ||
| 9291 | {"language", 'L', | ||
| 9292 | "Client error messages in given language. May be given as a full path. " | ||
| 9293 | "Deprecated. Use --lc-messages-dir instead.", | ||
| 9294 | &lc_messages_dir_ptr, &lc_messages_dir_ptr, nullptr, GET_STR, REQUIRED_ARG, | ||
| 9295 | 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9296 | {"lc-messages", 0, "Set the language used for the error messages.", | ||
| 9297 | &lc_messages, &lc_messages, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, | ||
| 9298 | nullptr, 0, nullptr}, | ||
| 9299 | {"lc-time-names", 0, | ||
| 9300 | "Set the language used for the month names and the days of the week.", | ||
| 9301 | &lc_time_names_name, &lc_time_names_name, nullptr, GET_STR, REQUIRED_ARG, | ||
| 9302 | 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9303 | {"log-bin", OPT_BIN_LOG, | ||
| 9304 | "Configures the name prefix to use for binary log files. If the --log-bin " | ||
| 9305 | "option is not supplied, the name prefix defaults to \"binlog\". If the " | ||
| 9306 | "--log-bin option is supplied without argument, the name prefix defaults " | ||
| 9307 | "to \"HOSTNAME-bin\", where HOSTNAME is the machine's hostname. To set a " | ||
| 9308 | "different name prefix for binary log files, use --log-bin=name. To " | ||
| 9309 | "disable " | ||
| 9310 | "binary logging, use the --skip-log-bin or --disable-log-bin option.", | ||
| 9311 | &opt_bin_logname, &opt_bin_logname, nullptr, GET_STR_ALLOC, OPT_ARG, 0, 0, | ||
| 9312 | 0, nullptr, 0, nullptr}, | ||
| 9313 | {"log-bin-index", 0, "File that holds the names for binary log files.", | ||
| 9314 | &opt_binlog_index_name, &opt_binlog_index_name, nullptr, GET_STR, | ||
| 9315 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9316 | {"relay-log-index", 0, "File that holds the names for relay log files.", | ||
| 9317 | &opt_relaylog_index_name, &opt_relaylog_index_name, nullptr, GET_STR, | ||
| 9318 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9319 | {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", | ||
| 9320 | &myisam_log_filename, &myisam_log_filename, nullptr, GET_STR, OPT_ARG, 0, | ||
| 9321 | 0, 0, nullptr, 0, nullptr}, | ||
| 9322 | {"log-short-format", 0, | ||
| 9323 | "Don't log extra information to update and slow-query logs.", | ||
| 9324 | &opt_short_log_format, &opt_short_log_format, nullptr, GET_BOOL, NO_ARG, 0, | ||
| 9325 | 0, 0, nullptr, 0, nullptr}, | ||
| 9326 | {"log-tc", 0, | ||
| 9327 | "Path to transaction coordinator log (used for transactions that affect " | ||
| 9328 | "more than one storage engine, when binary log is disabled).", | ||
| 9329 | &opt_tc_log_file, &opt_tc_log_file, nullptr, GET_STR, REQUIRED_ARG, 0, 0, | ||
| 9330 | 0, nullptr, 0, nullptr}, | ||
| 9331 | {"log-tc-size", 0, "Size of transaction coordinator log.", &opt_tc_log_size, | ||
| 9332 | &opt_tc_log_size, nullptr, GET_ULONG, REQUIRED_ARG, | ||
| 9333 | TC_LOG_MIN_PAGES *my_getpagesize(), TC_LOG_MIN_PAGES *my_getpagesize(), | ||
| 9334 | ULONG_MAX, nullptr, my_getpagesize(), nullptr}, | ||
| 9335 | {"master-info-file", OPT_MASTER_INFO_FILE, | ||
| 9336 | "The path and filename where the replication receiver thread stores " | ||
| 9337 | "connection configuration and positions, in case " | ||
| 9338 | "--master-info-repository=FILE. " | ||
| 9339 | "This option is deprecated and will be removed in a future version.", | ||
| 9340 | &master_info_file, &master_info_file, nullptr, GET_STR, REQUIRED_ARG, 0, 0, | ||
| 9341 | 0, nullptr, 0, nullptr}, | ||
| 9342 | {"master-retry-count", OPT_MASTER_RETRY_COUNT, | ||
| 9343 | "The number of times this replica will attempt to connect to a source " | ||
| 9344 | "before giving up. " | ||
| 9345 | "This option is deprecated and will be removed in a future version. " | ||
| 9346 | "Use 'CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT = <num>' instead.", | ||
| 9347 | &master_retry_count, &master_retry_count, nullptr, GET_ULONG, REQUIRED_ARG, | ||
| 9348 | 3600 * 24, 0, 0, nullptr, 0, nullptr}, | ||
| 9349 | {"max-binlog-dump-events", 0, | ||
| 9350 | "Option used by mysql-test for debugging and testing of replication.", | ||
| 9351 | &max_binlog_dump_events, &max_binlog_dump_events, nullptr, GET_INT, | ||
| 9352 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9353 | {"memlock", 0, "Lock mysqld in memory.", &locked_in_memory, | ||
| 9354 | &locked_in_memory, nullptr, GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, | ||
| 9355 | nullptr}, | ||
| 9356 | {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS, | ||
| 9357 | "Enable old-style user limits (before 5.0.3, user resources were counted " | ||
| 9358 | "for each user + host vs. per account). " | ||
| 9359 | "This option is deprecated and will be removed in a future version.", | ||
| 9360 | &opt_old_style_user_limits, &opt_old_style_user_limits, nullptr, GET_BOOL, | ||
| 9361 | NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9362 | {"port-open-timeout", 0, | ||
| 9363 | "Maximum time in seconds to wait for the port to become free. " | ||
| 9364 | "(Default: No wait).", | ||
| 9365 | &mysqld_port_timeout, &mysqld_port_timeout, nullptr, GET_UINT, | ||
| 9366 | REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9367 | {"replicate-do-db", OPT_REPLICATE_DO_DB, | ||
| 9368 | "Make replication applier threads apply only changes to the specified " | ||
| 9369 | "database. " | ||
| 9370 | "To specify more than one database, use the directive multiple times, " | ||
| 9371 | "once for each database. Note that this will only work if you do not use " | ||
| 9372 | "cross-database queries such as UPDATE some_db.some_table SET foo='bar' " | ||
| 9373 | "while having selected a different or no database. If you need cross " | ||
| 9374 | "database updates to work, make sure you have 3.23.28 or later, and use " | ||
| 9375 | "replicate-wild-do-table=db_name.%.", | ||
| 9376 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9377 | nullptr}, | ||
| 9378 | {"replicate-do-table", OPT_REPLICATE_DO_TABLE, | ||
| 9379 | "Make replication applier threads apply only changes to the specified " | ||
| 9380 | "table. " | ||
| 9381 | "To specify more than one table, use the directive multiple times, once " | ||
| 9382 | "for each table. This will work for cross-database updates, in contrast " | ||
| 9383 | "to replicate-do-db.", | ||
| 9384 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9385 | nullptr}, | ||
| 9386 | {"replica-enable-event", OPT_REPLICA_ENABLE_EVENT, | ||
| 9387 | "Tells the replication applier thread to enable the events that match " | ||
| 9388 | "the specified wildcard pattern without setting it as SLAVESIDE_DISABLED. " | ||
| 9389 | "To specify more than one event, use the directive multiple times, once " | ||
| 9390 | "for each event. This will work for cross-database events. Example: " | ||
| 9391 | "replica-enable-event=foo%.bar% will enable the events in all " | ||
| 9392 | "databases on replica server that start with 'foo' and whose event names " | ||
| 9393 | "start with 'bar'. It is recommended to use this feature only for " | ||
| 9394 | "read-only events to avoid data inconsistency.", | ||
| 9395 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9396 | nullptr}, | ||
| 9397 | {"replicate-ignore-db", OPT_REPLICATE_IGNORE_DB, | ||
| 9398 | "Make replication applier threads skip changes to the specified " | ||
| 9399 | "database. " | ||
| 9400 | "To specify more than one database to ignore, use this option multiple " | ||
| 9401 | "times, once for each database. If there are statements that update " | ||
| 9402 | "multiple databases, this will work correctly only when the source " | ||
| 9403 | "server uses binlog_format=ROW.", | ||
| 9404 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9405 | nullptr}, | ||
| 9406 | {"replicate-ignore-table", OPT_REPLICATE_IGNORE_TABLE, | ||
| 9407 | "Make replication applier threads skip changes to the specified table." | ||
| 9408 | "To ignore more than one table, use the option multiple times, once for " | ||
| 9409 | "each table. If there are statements that update multiple tables, this " | ||
| 9410 | "will work correctly only when the source server uses binlog_format=ROW.", | ||
| 9411 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9412 | nullptr}, | ||
| 9413 | {"replicate-rewrite-db", OPT_REPLICATE_REWRITE_DB, | ||
| 9414 | "Make replication applier threads rename a database, so changes in one " | ||
| 9415 | "database on the source will be applied in another database on this " | ||
| 9416 | "replica. Example: " | ||
| 9417 | "replicate-rewrite-db=source_db_name->replica_db_name.", | ||
| 9418 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9419 | nullptr}, | ||
| 9420 | {"replicate-same-server-id", 0, | ||
| 9421 | "In replication, if set to 1, do not skip events having our server id. " | ||
| 9422 | "Default value is 0 (to break infinite loops in circular replication). " | ||
| 9423 | "Can't be set to 1 if --log-replica-updates is used.", | ||
| 9424 | &replicate_same_server_id, &replicate_same_server_id, nullptr, GET_BOOL, | ||
| 9425 | NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9426 | {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, | ||
| 9427 | "Make replication applier threads apply changes only in tables that " | ||
| 9428 | "match the specified wildcard pattern. To specify more than one pattern, " | ||
| 9429 | "use the option multiple times, once for each pattern. If there are " | ||
| 9430 | "statements that update both tables that are included and excluded by " | ||
| 9431 | "the pattern, this will only work correctly when the source server uses " | ||
| 9432 | "binlog_format=ROW. " | ||
| 9433 | "Example: replicate-wild-do-table=foo%.bar% will " | ||
| 9434 | "replicate only updates to tables in all databases that start with foo " | ||
| 9435 | "and whose table names start with bar.", | ||
| 9436 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9437 | nullptr}, | ||
| 9438 | {"replicate-wild-ignore-table", OPT_REPLICATE_WILD_IGNORE_TABLE, | ||
| 9439 | "Make replication applier threads skip changes to tables that match " | ||
| 9440 | "the specified wildcard pattern. To specify more than one pattern, use " | ||
| 9441 | "the option multiple times, once for each pattern. If there are " | ||
| 9442 | "statements that update both tables that are included and tables that " | ||
| 9443 | "are excluded by the pattern, this will only work correctly when the " | ||
| 9444 | "source server uses binlog_format=ROW. " | ||
| 9445 | "Example: when using replicate-wild-ignore-table=foo%.bar%, " | ||
| 9446 | "the applier thread will not apply updates to tables in databases that " | ||
| 9447 | "start with foo and whose table names start with bar.", | ||
| 9448 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9449 | nullptr}, | ||
| 9450 | {"safe-user-create", 0, | ||
| 9451 | "Don't allow new user creation by the user who has no write privileges to " | ||
| 9452 | "the mysql.user table.", | ||
| 9453 | &opt_safe_user_create, &opt_safe_user_create, nullptr, GET_BOOL, NO_ARG, 0, | ||
| 9454 | 0, 0, nullptr, 0, nullptr}, | ||
| 9455 | {"show-replica-auth-info", 0, | ||
| 9456 | "Include user and password in SHOW REPLICAS statements.", | ||
| 9457 | &opt_show_replica_auth_info, &opt_show_replica_auth_info, nullptr, | ||
| 9458 | GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9459 | {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO_DEPRECATED, | ||
| 9460 | "This option is deprecated and will be removed in a future version. " | ||
| 9461 | "Use show-replica-auth-info instead.", | ||
| 9462 | &opt_show_replica_auth_info, &opt_show_replica_auth_info, nullptr, | ||
| 9463 | GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9464 | {"skip-host-cache", OPT_SKIP_HOST_CACHE_DEPRECATED, | ||
| 9465 | "Don't cache host names.", nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, | ||
| 9466 | 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9467 | {"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.", | ||
| 9468 | nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, 0, nullptr, 0, | ||
| 9469 | nullptr}, | ||
| 9470 | #if defined(_WIN32) | ||
| 9471 | {"slow-start-timeout", 0, | ||
| 9472 | "Maximum number of milliseconds that the service control manager should " | ||
| 9473 | "wait " | ||
| 9474 | "before trying to kill the windows service during startup" | ||
| 9475 | "(Default: 15000).", | ||
| 9476 | &slow_start_timeout, &slow_start_timeout, 0, GET_ULONG, REQUIRED_ARG, | ||
| 9477 | 15000, 0, 0, 0, 0, 0}, | ||
| 9478 | #endif | ||
| 9479 | {"sporadic-binlog-dump-fail", 0, | ||
| 9480 | "Option used by mysql-test for debugging and testing of replication.", | ||
| 9481 | &opt_sporadic_binlog_dump_fail, &opt_sporadic_binlog_dump_fail, nullptr, | ||
| 9482 | GET_BOOL, NO_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9483 | {"ssl", OPT_USE_SSL, | ||
| 9484 | "Enable SSL for connection (automatically enabled with other flags).", | ||
| 9485 | &opt_use_ssl, &opt_use_ssl, nullptr, GET_BOOL, OPT_ARG, 1, 0, 0, nullptr, | ||
| 9486 | 0, nullptr}, | ||
| 9487 | {"admin-ssl", OPT_USE_ADMIN_SSL, | ||
| 9488 | "Enable SSL for admin interface (automatically enabled with other flags).", | ||
| 9489 | &opt_use_admin_ssl, &opt_use_admin_ssl, nullptr, GET_BOOL, OPT_ARG, 1, 0, | ||
| 9490 | 0, nullptr, 0, nullptr}, | ||
| 9491 | #ifdef _WIN32 | ||
| 9492 | {"standalone", 0, "Dummy option to start as a standalone program (NT).", 0, | ||
| 9493 | 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
| 9494 | {"no-monitor", 0, "Disable monitor process.", &opt_no_monitor, | ||
| 9495 | &opt_no_monitor, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, | ||
| 9496 | #endif | ||
| 9497 | {"symbolic-links", 's', | ||
| 9498 | "Enable symbolic link support (deprecated and will be removed in a future" | ||
| 9499 | " release).", | ||
| 9500 | &my_enable_symlinks, &my_enable_symlinks, nullptr, GET_BOOL, NO_ARG, 0, 0, | ||
| 9501 | 0, nullptr, 0, nullptr}, | ||
| 9502 | {"sysdate-is-now", 0, | ||
| 9503 | "Non-default option to alias SYSDATE() to NOW() to make it " | ||
| 9504 | "safe-replicable. " | ||
| 9505 | "Since 5.0, SYSDATE() returns a `dynamic' value different for different " | ||
| 9506 | "invocations, even within the same statement.", | ||
| 9507 | &global_system_variables.sysdate_is_now, nullptr, nullptr, GET_BOOL, | ||
| 9508 | NO_ARG, 0, 0, 1, nullptr, 1, nullptr}, | ||
| 9509 | {"tc-heuristic-recover", 0, | ||
| 9510 | "Decision to use in heuristic recover process. Possible values are OFF, " | ||
| 9511 | "COMMIT or ROLLBACK.", | ||
| 9512 | &tc_heuristic_recover, &tc_heuristic_recover, | ||
| 9513 | &tc_heuristic_recover_typelib, GET_ENUM, REQUIRED_ARG, | ||
| 9514 | TC_HEURISTIC_NOT_USED, 0, 0, nullptr, 0, nullptr}, | ||
| 9515 | #if defined(ENABLED_DEBUG_SYNC) | ||
| 9516 | {"debug-sync-timeout", OPT_DEBUG_SYNC_TIMEOUT, | ||
| 9517 | "Enable the debug sync facility " | ||
| 9518 | "and optionally specify a default wait timeout in seconds. " | ||
| 9519 | "A zero value keeps the facility disabled.", | ||
| 9520 | &opt_debug_sync_timeout, nullptr, nullptr, GET_UINT, OPT_ARG, 0, 0, | ||
| 9521 | UINT_MAX, nullptr, 0, nullptr}, | ||
| 9522 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 9523 | {"transaction-isolation", 0, "Default transaction isolation level.", | ||
| 9524 | &global_system_variables.transaction_isolation, | ||
| 9525 | &global_system_variables.transaction_isolation, &tx_isolation_typelib, | ||
| 9526 | GET_ENUM, REQUIRED_ARG, ISO_REPEATABLE_READ, 0, 0, nullptr, 0, nullptr}, | ||
| 9527 | {"transaction-read-only", 0, | ||
| 9528 | "Default transaction access mode. " | ||
| 9529 | "True if transactions are read-only.", | ||
| 9530 | &global_system_variables.transaction_read_only, | ||
| 9531 | &global_system_variables.transaction_read_only, nullptr, GET_BOOL, OPT_ARG, | ||
| 9532 | 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9533 | {"user", 'u', "Run mysqld daemon as user.", nullptr, nullptr, nullptr, | ||
| 9534 | GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, nullptr}, | ||
| 9535 | {"early-plugin-load", OPT_EARLY_PLUGIN_LOAD, | ||
| 9536 | "Optional semicolon-separated list of plugins to load before storage " | ||
| 9537 | "engine " | ||
| 9538 | "initialization, where each plugin is identified as name=library, where " | ||
| 9539 | "name is the plugin name and library is the plugin library in plugin_dir.", | ||
| 9540 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9541 | nullptr}, | ||
| 9542 | {"plugin-load", OPT_PLUGIN_LOAD, | ||
| 9543 | "Optional semicolon-separated list of plugins to load, where each plugin " | ||
| 9544 | "is " | ||
| 9545 | "identified as name=library, where name is the plugin name and library " | ||
| 9546 | "is the plugin library in plugin_dir.", | ||
| 9547 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9548 | nullptr}, | ||
| 9549 | {"plugin-load-add", OPT_PLUGIN_LOAD_ADD, | ||
| 9550 | "Optional semicolon-separated list of plugins to load, where each plugin " | ||
| 9551 | "is " | ||
| 9552 | "identified as name=library, where name is the plugin name and library " | ||
| 9553 | "is the plugin library in plugin_dir. This option adds to the list " | ||
| 9554 | "specified by --plugin-load in an incremental way. " | ||
| 9555 | "Multiple --plugin-load-add are supported.", | ||
| 9556 | nullptr, nullptr, nullptr, GET_STR, REQUIRED_ARG, 0, 0, 0, nullptr, 0, | ||
| 9557 | nullptr}, | ||
| 9558 | |||
| 9559 | {"innodb", OPT_SKIP_INNODB, | ||
| 9560 | "Deprecated option. Provided for backward compatibility only. " | ||
| 9561 | "The option has no effect on the server behaviour. InnoDB is always " | ||
| 9562 | "enabled. " | ||
| 9563 | "The option will be removed in a future release.", | ||
| 9564 | nullptr, nullptr, nullptr, GET_BOOL, OPT_ARG, 0, 0, 0, nullptr, 0, | ||
| 9565 | nullptr}, | ||
| 9566 | |||
| 9567 | {"upgrade", 0, | ||
| 9568 | "Set server upgrade mode. NONE to abort server if automatic upgrade of " | ||
| 9569 | "the server is needed; MINIMAL to start the server, but skip upgrade " | ||
| 9570 | "steps that are not absolutely necessary; AUTO (default) to upgrade the " | ||
| 9571 | "server if required; FORCE to force upgrade server.", | ||
| 9572 | &opt_upgrade_mode, &opt_upgrade_mode, &upgrade_mode_typelib, GET_ENUM, | ||
| 9573 | REQUIRED_ARG, UPGRADE_AUTO, 0, 0, nullptr, 0, nullptr}, | ||
| 9574 | |||
| 9575 | {"utility_user", 0, | ||
| 9576 | "Specifies a MySQL user that will be added to the " | ||
| 9577 | "internal list of users and recognized as the utility user.", | ||
| 9578 | &utility_user, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
| 9579 | {"utility_user_password", 0, | ||
| 9580 | "Specifies the password required for the " | ||
| 9581 | "utility user.", | ||
| 9582 | &utility_user_password, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
| 9583 | {"utility_user_privileges", 0, | ||
| 9584 | "Specifies the privileges that the utility " | ||
| 9585 | "user will have in a comma delimited list. See the manual for a complete " | ||
| 9586 | "list of privileges.", | ||
| 9587 | &utility_user_privileges, 0, &utility_user_privileges_typelib, GET_SET, | ||
| 9588 | REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, | ||
| 9589 | {"utility_user_dynamic_privileges", 0, | ||
| 9590 | "Specifies the dynamic privileges that the utility " | ||
| 9591 | "user will have in a comma delimited list. See the manual for a complete " | ||
| 9592 | "list of privileges.", | ||
| 9593 | &utility_user_dynamic_privileges, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, | ||
| 9594 | 0, 0}, | ||
| 9595 | 110009 | {"utility_user_schema_access", 0, | |
| 9596 | 110009 | "Specifies the schemas that the utility " | |
| 9597 | 110009 | "user has access to in a comma delimited list.", | |
| 9598 | 110009 | &utility_user_schema_access, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, | |
| 9599 | 0}, | ||
| 9600 | |||
| 9601 | 57555 | {nullptr, 0, nullptr, nullptr, nullptr, nullptr, GET_NO_ARG, NO_ARG, 0, 0, | |
| 9602 | 57555 | 0, nullptr, 0, nullptr}}; | |
| 9603 | 57555 | ||
| 9604 | 57555 | static int show_queries(THD *thd, SHOW_VAR *var, char *) { | |
| 9605 | 57555 | var->type = SHOW_LONGLONG; | |
| 9606 | var->value = (char *)&thd->query_id; | ||
| 9607 | return 0; | ||
| 9608 | 57555 | } | |
| 9609 | 57555 | ||
| 9610 | 57555 | static int show_net_compression(THD *thd, SHOW_VAR *var, char *buff) { | |
| 9611 | 57555 | var->type = SHOW_MY_BOOL; | |
| 9612 |
2/2✓ Branch 0 taken 85 times.
✓ Branch 1 taken 57470 times.
|
57555 | var->value = buff; |
| 9613 | 57555 | *((bool *)buff) = thd->get_protocol()->get_compression(); | |
| 9614 | return 0; | ||
| 9615 | } | ||
| 9616 | 57555 | ||
| 9617 | 57555 | static int show_net_compression_algorithm(THD *thd, SHOW_VAR *var, char *buff) { | |
| 9618 | 57555 | const char *s = thd->get_protocol()->get_compression_algorithm(); | |
| 9619 | 57555 | var->type = SHOW_CHAR; | |
| 9620 | 57555 | var->value = buff; | |
| 9621 | 57555 | sprintf(buff, "%s", (s ? s : "")); | |
| 9622 | return 0; | ||
| 9623 | } | ||
| 9624 | 109342 | ||
| 9625 | 109342 | static int show_net_compression_level(THD *thd, SHOW_VAR *var, char *buff) { | |
| 9626 | 109342 | var->type = SHOW_INT; | |
| 9627 | 109342 | var->value = buff; | |
| 9628 | 109342 | unsigned int *value = reinterpret_cast<unsigned int *>(buff); | |
| 9629 | 109342 | *value = thd->get_protocol()->get_compression_level(); | |
| 9630 | return 0; | ||
| 9631 | } | ||
| 9632 | 109346 | ||
| 9633 | static int show_starttime(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9634 | 109346 | var->type = SHOW_LONGLONG; | |
| 9635 | 109346 | var->value = buff; | |
| 9636 |
1/2✓ Branch 0 taken 109346 times.
✗ Branch 1 not taken.
|
109346 | *((longlong *)buff) = |
| 9637 | (longlong)(thd->query_start_in_secs() - server_start_time); | ||
| 9638 | return 0; | ||
| 9639 |
1/2✓ Branch 0 taken 109346 times.
✗ Branch 1 not taken.
|
109346 | } |
| 9640 | 109346 | ||
| 9641 | static int show_max_used_connections_time(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9642 | MYSQL_TIME max_used_connections_time; | ||
| 9643 | 109342 | var->type = SHOW_CHAR; | |
| 9644 | 109342 | var->value = buff; | |
| 9645 | 109342 | thd->variables.time_zone->gmt_sec_to_TIME( | |
| 9646 | 109342 | &max_used_connections_time, | |
| 9647 | 109342 | Connection_handler_manager::max_used_connections_time); | |
| 9648 | 109342 | my_datetime_to_str(max_used_connections_time, buff, 0); | |
| 9649 | 109342 | return 0; | |
| 9650 | } | ||
| 9651 | |||
| 9652 | 109342 | static int show_num_thread_running(THD *, SHOW_VAR *var, char *buff) { | |
| 9653 | 109342 | var->type = SHOW_LONGLONG; | |
| 9654 | 109342 | var->value = buff; | |
| 9655 | 109342 | long long *value = reinterpret_cast<long long *>(buff); | |
| 9656 | 109342 | *value = static_cast<long long>( | |
| 9657 | 109342 | Global_THD_manager::get_instance()->get_num_thread_running()); | |
| 9658 | 109342 | return 0; | |
| 9659 | } | ||
| 9660 | |||
| 9661 | 109351 | static int show_num_thread_created(THD *, SHOW_VAR *var, char *buff) { | |
| 9662 | 109351 | var->type = SHOW_LONG; | |
| 9663 | 109351 | var->value = buff; | |
| 9664 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9665 | 109351 | *value = static_cast<long>( | |
| 9666 | 109351 | Global_THD_manager::get_instance()->get_num_thread_created()); | |
| 9667 | 109351 | return 0; | |
| 9668 | } | ||
| 9669 | |||
| 9670 | 109351 | static int show_thread_id_count(THD *, SHOW_VAR *var, char *buff) { | |
| 9671 | 109351 | var->type = SHOW_LONG; | |
| 9672 | 109351 | var->value = buff; | |
| 9673 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9674 | 109351 | *value = static_cast<long>( | |
| 9675 | 109351 | Global_THD_manager::get_instance()->get_thread_id() - 1); | |
| 9676 | 109351 | return 0; | |
| 9677 | } | ||
| 9678 | |||
| 9679 | 109351 | static int show_aborted_connects(THD *, SHOW_VAR *var, char *buff) { | |
| 9680 | 109351 | var->type = SHOW_LONG; | |
| 9681 | 109351 | var->value = buff; | |
| 9682 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9683 | 109351 | *value = static_cast<long>( | |
| 9684 | 109351 | Connection_handler_manager::get_instance()->aborted_connects()); | |
| 9685 | return 0; | ||
| 9686 | } | ||
| 9687 | 109351 | ||
| 9688 | static int show_acl_cache_items_count(THD *, SHOW_VAR *var, char *buff) { | ||
| 9689 | 109351 | var->type = SHOW_LONG; | |
| 9690 | 109351 | var->value = buff; | |
| 9691 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9692 | 109351 | *value = static_cast<long>(get_global_acl_cache_size()); | |
| 9693 | 109351 | return 0; | |
| 9694 | 109351 | } | |
| 9695 | |||
| 9696 | static int show_connection_errors_max_connection(THD *, SHOW_VAR *var, | ||
| 9697 | 109351 | char *buff) { | |
| 9698 | var->type = SHOW_LONG; | ||
| 9699 | 109351 | var->value = buff; | |
| 9700 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9701 | 109351 | *value = static_cast<long>(Connection_handler_manager::get_instance() | |
| 9702 | 109351 | ->connection_errors_max_connection()); | |
| 9703 | 109351 | return 0; | |
| 9704 | } | ||
| 9705 | |||
| 9706 | 109351 | static int show_connection_errors_query_block(THD *, SHOW_VAR *var, | |
| 9707 | 109351 | char *buff) { | |
| 9708 | 109351 | var->type = SHOW_LONG; | |
| 9709 | 109351 | var->value = buff; | |
| 9710 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9711 | 109351 | *value = static_cast<long>(get_connection_errors_query_block()); | |
| 9712 | return 0; | ||
| 9713 | } | ||
| 9714 | 109351 | ||
| 9715 | 109351 | static int show_connection_errors_accept(THD *, SHOW_VAR *var, char *buff) { | |
| 9716 | 109351 | var->type = SHOW_LONG; | |
| 9717 | 109351 | var->value = buff; | |
| 9718 | 109351 | long *value = reinterpret_cast<long *>(buff); | |
| 9719 | 109351 | *value = static_cast<long>(get_connection_errors_accept()); | |
| 9720 | return 0; | ||
| 9721 | } | ||
| 9722 | |||
| 9723 | 109342 | static int show_connection_errors_tcpwrap(THD *, SHOW_VAR *var, char *buff) { | |
| 9724 | 109342 | var->type = SHOW_LONG; | |
| 9725 | 109342 | var->value = buff; | |
| 9726 | 109342 | long *value = reinterpret_cast<long *>(buff); | |
| 9727 | 109342 | *value = static_cast<long>(get_connection_errors_tcpwrap()); | |
| 9728 | 109342 | return 0; | |
| 9729 | } | ||
| 9730 | |||
| 9731 | #ifdef ENABLED_PROFILING | ||
| 9732 | static int show_flushstatustime(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9733 | 218684 | var->type = SHOW_LONGLONG; | |
| 9734 | var->value = buff; | ||
| 9735 | 218684 | *((longlong *)buff) = | |
| 9736 | 218684 | (longlong)(thd->query_start_in_secs() - flush_status_time); | |
| 9737 | return 0; | ||
| 9738 |
2/2✓ Branch 0 taken 218526 times.
✓ Branch 1 taken 158 times.
|
437210 | } |
| 9739 |
2/2✓ Branch 0 taken 1340 times.
✓ Branch 1 taken 217186 times.
|
218526 | #endif |
| 9740 | |||
| 9741 | #ifndef NDEBUG | ||
| 9742 | 218684 | static int show_replica_rows_last_search_algorithm_used(THD *, SHOW_VAR *var, | |
| 9743 | 218684 | char *buff) { | |
| 9744 | 218684 | uint res = replica_rows_last_search_algorithm_used; | |
| 9745 | const char *s = | ||
| 9746 | 218684 | ((res == Rows_log_event::ROW_LOOKUP_TABLE_SCAN) | |
| 9747 | ? "TABLE_SCAN" | ||
| 9748 | : ((res == Rows_log_event::ROW_LOOKUP_HASH_SCAN) ? "HASH_SCAN" | ||
| 9749 | 109342 | : "INDEX_SCAN")); | |
| 9750 | |||
| 9751 | 109342 | var->type = SHOW_CHAR; | |
| 9752 | 109342 | var->value = buff; | |
| 9753 | 109342 | sprintf(buff, "%s", s); | |
| 9754 | |||
| 9755 | 109342 | return 0; | |
| 9756 | } | ||
| 9757 | |||
| 9758 | 109342 | static int show_ongoing_automatic_gtid_violating_transaction_count( | |
| 9759 | THD *, SHOW_VAR *var, char *buf) { | ||
| 9760 | 109342 | var->type = SHOW_CHAR; | |
| 9761 | 109342 | var->value = buf; | |
| 9762 | 109342 | sprintf(buf, "%d", | |
| 9763 | gtid_state->get_automatic_gtid_violating_transaction_count()); | ||
| 9764 | 109342 | return 0; | |
| 9765 | } | ||
| 9766 | |||
| 9767 | static int show_ongoing_anonymous_gtid_violating_transaction_count( | ||
| 9768 | THD *, SHOW_VAR *var, char *buf) { | ||
| 9769 | 109342 | var->type = SHOW_CHAR; | |
| 9770 | var->value = buf; | ||
| 9771 | 109342 | sprintf(buf, "%d", | |
| 9772 | 109342 | gtid_state->get_anonymous_gtid_violating_transaction_count()); | |
| 9773 | 109342 | return 0; | |
| 9774 | 109342 | } | |
| 9775 | |||
| 9776 | #endif | ||
| 9777 | 110009 | ||
| 9778 | 110009 | static int show_ongoing_anonymous_transaction_count(THD *, SHOW_VAR *var, | |
| 9779 | 110009 | char *buf) { | |
| 9780 | 110009 | var->type = SHOW_CHAR; | |
| 9781 | 110009 | var->value = buf; | |
| 9782 | sprintf(buf, "%d", gtid_state->get_anonymous_ownership_count()); | ||
| 9783 | return 0; | ||
| 9784 | 109342 | } | |
| 9785 | 109342 | ||
| 9786 | 109342 | static int show_open_tables(THD *, SHOW_VAR *var, char *buff) { | |
| 9787 | 109342 | var->type = SHOW_LONG; | |
| 9788 | 109342 | var->value = buff; | |
| 9789 | 109342 | *((long *)buff) = (long)table_cache_manager.cached_tables(); | |
| 9790 | 109342 | return 0; | |
| 9791 | } | ||
| 9792 | |||
| 9793 | 109351 | static int show_prepared_stmt_count(THD *, SHOW_VAR *var, char *buff) { | |
| 9794 | 109351 | var->type = SHOW_LONG; | |
| 9795 | 109351 | var->value = buff; | |
| 9796 | 109351 | mysql_mutex_lock(&LOCK_prepared_stmt_count); | |
| 9797 | 109351 | *((long *)buff) = (long)prepared_stmt_count; | |
| 9798 | 218702 | mysql_mutex_unlock(&LOCK_prepared_stmt_count); | |
| 9799 | 109351 | return 0; | |
| 9800 | } | ||
| 9801 | 109342 | ||
| 9802 | 109342 | static int show_global_mem_counter(THD *, SHOW_VAR *var, char *buff) { | |
| 9803 | 109342 | var->type = SHOW_LONGLONG; | |
| 9804 | 109342 | var->value = buff; | |
| 9805 | 109342 | MUTEX_LOCK(lock, &LOCK_global_conn_mem_limit); | |
| 9806 | *((longlong *)buff) = (longlong)global_conn_mem_counter; | ||
| 9807 | return 0; | ||
| 9808 | } | ||
| 9809 | |||
| 9810 | static int show_table_definitions(THD *, SHOW_VAR *var, char *buff) { | ||
| 9811 | var->type = SHOW_LONG; | ||
| 9812 | var->value = buff; | ||
| 9813 | *((long *)buff) = (long)cached_table_definitions(); | ||
| 9814 | return 0; | ||
| 9815 | 110009 | } | |
| 9816 | 110009 | ||
| 9817 | 110009 | /* | |
| 9818 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | Functions relying on SSL |
| 9819 | 194 | Note: In the show_ssl_* functions, we need to check if we have a | |
| 9820 | valid vio-object since this isn't always true, specifically | ||
| 9821 | 109815 | when session_status or global_status is requested from | |
| 9822 | 110009 | inside an Event. | |
| 9823 | */ | ||
| 9824 | static int show_ssl_get_version(THD *thd, SHOW_VAR *var, char *) { | ||
| 9825 | 110009 | SSL_handle ssl = thd->get_ssl(); | |
| 9826 | 110009 | var->type = SHOW_CHAR; | |
| 9827 | 110009 | if (ssl) | |
| 9828 | 110009 | var->value = const_cast<char *>(SSL_get_version(ssl)); | |
| 9829 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | else |
| 9830 | 194 | var->value = const_cast<char *>(""); | |
| 9831 | return 0; | ||
| 9832 | 109815 | } | |
| 9833 | 110009 | ||
| 9834 | static int show_ssl_session_reused(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9835 | SSL_handle ssl = thd->get_ssl(); | ||
| 9836 | 110009 | var->type = SHOW_LONG; | |
| 9837 | 110009 | var->value = buff; | |
| 9838 | 110009 | if (ssl) | |
| 9839 | 110009 | *((long *)buff) = (long)SSL_session_reused(ssl); | |
| 9840 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | else |
| 9841 | 194 | *((long *)buff) = 0; | |
| 9842 | return 0; | ||
| 9843 | 109815 | } | |
| 9844 | 110009 | ||
| 9845 | static int show_ssl_get_default_timeout(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9846 | SSL_handle ssl = thd->get_ssl(); | ||
| 9847 | 110009 | var->type = SHOW_LONG; | |
| 9848 | 110009 | var->value = buff; | |
| 9849 | 110009 | if (ssl) | |
| 9850 | 110009 | *((long *)buff) = (long)SSL_get_default_timeout(ssl); | |
| 9851 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | else |
| 9852 | 194 | *((long *)buff) = 0; | |
| 9853 | return 0; | ||
| 9854 | 109815 | } | |
| 9855 | 110009 | ||
| 9856 | static int show_ssl_get_verify_mode(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9857 | SSL_handle ssl = thd->get_ssl(); | ||
| 9858 | 110009 | var->type = SHOW_LONG; | |
| 9859 | 110009 | var->value = buff; | |
| 9860 | 110009 | if (ssl) | |
| 9861 | 110009 | *((long *)buff) = (long)SSL_get_verify_mode(ssl); | |
| 9862 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | else |
| 9863 | 194 | *((long *)buff) = 0; | |
| 9864 | return 0; | ||
| 9865 | 109815 | } | |
| 9866 | 110009 | ||
| 9867 | static int show_ssl_get_verify_depth(THD *thd, SHOW_VAR *var, char *buff) { | ||
| 9868 | SSL_handle ssl = thd->get_ssl(); | ||
| 9869 | 110009 | var->type = SHOW_LONG; | |
| 9870 | 110009 | var->value = buff; | |
| 9871 | 110009 | if (ssl) | |
| 9872 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | *((long *)buff) = (long)SSL_get_verify_depth(ssl); |
| 9873 | 194 | else | |
| 9874 | *((long *)buff) = 0; | ||
| 9875 | 109815 | return 0; | |
| 9876 | 110009 | } | |
| 9877 | |||
| 9878 | static int show_ssl_get_cipher(THD *thd, SHOW_VAR *var, char *) { | ||
| 9879 | 110009 | SSL_handle ssl = thd->get_ssl(); | |
| 9880 | 110009 | var->type = SHOW_CHAR; | |
| 9881 | 110009 | if (ssl) | |
| 9882 | 110009 | var->value = const_cast<char *>(SSL_get_cipher(ssl)); | |
| 9883 |
2/2✓ Branch 0 taken 194 times.
✓ Branch 1 taken 109815 times.
|
110009 | else |
| 9884 | var->value = const_cast<char *>(""); | ||
| 9885 | return 0; | ||
| 9886 | 194 | } | |
| 9887 |
5/6✓ Branch 0 taken 5905 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 5905 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5905 times.
✓ Branch 5 taken 194 times.
|
6099 | |
| 9888 | 5905 | static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff) { | |
| 9889 | 5905 | SSL_handle ssl = thd->get_ssl(); | |
| 9890 | var->type = SHOW_CHAR; | ||
| 9891 |
1/2✓ Branch 0 taken 194 times.
✗ Branch 1 not taken.
|
194 | var->value = buff; |
| 9892 | if (ssl) { | ||
| 9893 | 110009 | int i; | |
| 9894 | 110009 | const char *p; | |
| 9895 | char *end = buff + SHOW_VAR_FUNC_BUFF_SIZE; | ||
| 9896 | for (i = 0; (p = SSL_get_cipher_list(ssl, i)) && buff < end; i++) { | ||
| 9897 | buff = my_stpnmov(buff, p, end - buff - 1); | ||
| 9898 | 109342 | *buff++ = ':'; | |
| 9899 | } | ||
| 9900 | 109342 | if (i) buff--; | |
| 9901 | 109342 | } | |
| 9902 | 109342 | *buff = 0; | |
| 9903 | 109342 | return 0; | |
| 9904 | } | ||
| 9905 | |||
| 9906 | #ifdef HAVE_POOL_OF_THREADS | ||
| 9907 | 218684 | static int show_threadpool_idle_threads(THD *thd [[maybe_unused]], | |
| 9908 | 218684 | SHOW_VAR *var, char *buff) { | |
| 9909 | 218684 | var->type = SHOW_INT; | |
| 9910 | 218684 | var->value = buff; | |
| 9911 | 218684 | *(int *)buff = tp_get_idle_thread_count(); | |
| 9912 | return 0; | ||
| 9913 | 5 | } | |
| 9914 | #endif | ||
| 9915 |
3/4✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
|
5 | |
| 9916 | static int show_replica_open_temp_tables(THD *, SHOW_VAR *var, char *buf) { | ||
| 9917 | var->type = SHOW_INT; | ||
| 9918 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | var->value = buf; |
| 9919 | *((int *)buf) = atomic_replica_open_temp_tables; | ||
| 9920 | 1 | return 0; | |
| 9921 | } | ||
| 9922 | bool validate_libcoredumper_path(char *libcoredumper_path) { | ||
| 9923 | /* validate path */ | ||
| 9924 | 4 | if (!is_valid_log_name( | |
| 9925 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | libcoredumper_path, |
| 9926 | strlen(libcoredumper_path))) { // filename contain .cnf or .ini on it | ||
| 9927 | sql_print_error("Variable --coredumper cannot be set to value %s", | ||
| 9928 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
4 | libcoredumper_path); |
| 9929 | ✗ | return false; | |
| 9930 | } | ||
| 9931 | ✗ | char libcoredumper_dir[FN_REFLEN]; | |
| 9932 | size_t libcoredumper_dir_length; | ||
| 9933 | 4 | size_t opt_libcoredumper_path_length = strlen(libcoredumper_path); | |
| 9934 | 4 | (void)dirname_part(libcoredumper_dir, libcoredumper_path, | |
| 9935 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | &libcoredumper_dir_length); |
| 9936 | |||
| 9937 | 1 | if (!libcoredumper_dir_length) { | |
| 9938 | sql_print_error("Error processing --coredumper path: %s", | ||
| 9939 | 3 | libcoredumper_path); | |
| 9940 | return false; | ||
| 9941 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | } |
| 9942 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | size_t libcoredumper_file_length = |
| 9943 | 1 | opt_libcoredumper_path_length - libcoredumper_dir_length; | |
| 9944 | if (libcoredumper_file_length == 0) // path is a directory | ||
| 9945 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
|
3 | { |
| 9946 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | libcoredumper_file_length = 19; // file is set to core.yyyymmddhhmmss |
| 9947 | 1 | } else { | |
| 9948 | libcoredumper_file_length += 15; // file gets .yyyymmddhhmmss appended | ||
| 9949 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 1 times.
|
2 | } |
| 9950 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (opt_libcoredumper_path_length > FN_REFLEN) { // path is too long |
| 9951 | sql_print_error("Variable --coredumper set to a too long path"); | ||
| 9952 | 1 | return false; | |
| 9953 | } | ||
| 9954 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (libcoredumper_file_length > FN_LEN) { // filename is too long |
| 9955 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | sql_print_error("Variable --coredumper set to a too long filename"); |
| 9956 | return false; | ||
| 9957 | 1 | } | |
| 9958 | if (my_access(libcoredumper_dir, F_OK)) { | ||
| 9959 | ✗ | sql_print_error("Directory specified at --coredumper: %s does not exist", | |
| 9960 | ✗ | libcoredumper_dir); | |
| 9961 | return false; | ||
| 9962 | ✗ | } | |
| 9963 | if (my_access(libcoredumper_dir, (F_OK | W_OK))) { | ||
| 9964 | ✗ | sql_print_error("Directory specified at --coredumper: %s is not writable", | |
| 9965 | libcoredumper_dir); | ||
| 9966 | return false; | ||
| 9967 | 109342 | } | |
| 9968 | if (libcoredumper_dir_length == | ||
| 9969 | strlen(libcoredumper_path)) { // only dirname was specified, append core | ||
| 9970 | // to libcoredumper_path | ||
| 9971 | 109342 | strcat(libcoredumper_path, "core"); | |
| 9972 | } | ||
| 9973 | 109342 | return true; | |
| 9974 | 109342 | } | |
| 9975 | 109342 | ||
| 9976 | 109342 | static int show_tls_library_version(THD *, SHOW_VAR *var, char *buff) { | |
| 9977 | #if OPENSSL_VERSION_NUMBER <= 0x10100000L | ||
| 9978 | strncpy(buff, SSLeay_version(SSLEAY_VERSION), SHOW_VAR_FUNC_BUFF_SIZE); | ||
| 9979 | #else | ||
| 9980 | strncpy(buff, OpenSSL_version(OPENSSL_VERSION), SHOW_VAR_FUNC_BUFF_SIZE); | ||
| 9981 | #endif | ||
| 9982 | buff[SHOW_VAR_FUNC_BUFF_SIZE - 1] = 0; | ||
| 9983 | var->type = SHOW_CHAR; | ||
| 9984 | var->value = buff; | ||
| 9985 | return 0; | ||
| 9986 | } | ||
| 9987 | |||
| 9988 | /* | ||
| 9989 | Variables shown by SHOW STATUS in alphabetical order | ||
| 9990 | */ | ||
| 9991 | SHOW_VAR status_vars[] = { | ||
| 9992 | {"Aborted_clients", (char *)&aborted_threads, SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 9993 | {"Aborted_connects", (char *)&show_aborted_connects, SHOW_FUNC, | ||
| 9994 | SHOW_SCOPE_GLOBAL}, | ||
| 9995 | {"Acl_cache_items_count", (char *)&show_acl_cache_items_count, SHOW_FUNC, | ||
| 9996 | SHOW_SCOPE_GLOBAL}, | ||
| 9997 | #ifndef NDEBUG | ||
| 9998 | {"Ongoing_anonymous_gtid_violating_transaction_count", | ||
| 9999 | (char *)&show_ongoing_anonymous_gtid_violating_transaction_count, | ||
| 10000 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10001 | #endif //! NDEBUG | ||
| 10002 | {"Ongoing_anonymous_transaction_count", | ||
| 10003 | (char *)&show_ongoing_anonymous_transaction_count, SHOW_FUNC, | ||
| 10004 | SHOW_SCOPE_GLOBAL}, | ||
| 10005 | #ifndef NDEBUG | ||
| 10006 | {"Ongoing_automatic_gtid_violating_transaction_count", | ||
| 10007 | (char *)&show_ongoing_automatic_gtid_violating_transaction_count, | ||
| 10008 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10009 | #endif //! NDEBUG | ||
| 10010 | {"Binlog_cache_disk_use", (char *)&binlog_cache_disk_use, SHOW_LONG, | ||
| 10011 | SHOW_SCOPE_GLOBAL}, | ||
| 10012 | {"Binlog_cache_use", (char *)&binlog_cache_use, SHOW_LONG, | ||
| 10013 | SHOW_SCOPE_GLOBAL}, | ||
| 10014 | {"Binlog_stmt_cache_disk_use", (char *)&binlog_stmt_cache_disk_use, | ||
| 10015 | SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10016 | {"Binlog_stmt_cache_use", (char *)&binlog_stmt_cache_use, SHOW_LONG, | ||
| 10017 | SHOW_SCOPE_GLOBAL}, | ||
| 10018 | {"Bytes_received", (char *)offsetof(System_status_var, bytes_received), | ||
| 10019 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10020 | {"Bytes_sent", (char *)offsetof(System_status_var, bytes_sent), | ||
| 10021 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10022 | {"Com", (char *)com_status_vars, SHOW_ARRAY, SHOW_SCOPE_ALL}, | ||
| 10023 | {"Com_stmt_reprepare", | ||
| 10024 | (char *)offsetof(System_status_var, com_stmt_reprepare), SHOW_LONG_STATUS, | ||
| 10025 | SHOW_SCOPE_ALL}, | ||
| 10026 | {"Compression", (char *)&show_net_compression, SHOW_FUNC, | ||
| 10027 | SHOW_SCOPE_SESSION}, | ||
| 10028 | {"Compression_algorithm", (char *)&show_net_compression_algorithm, | ||
| 10029 | SHOW_FUNC, SHOW_SCOPE_SESSION}, | ||
| 10030 | {"Compression_level", (char *)&show_net_compression_level, SHOW_FUNC, | ||
| 10031 | SHOW_SCOPE_SESSION}, | ||
| 10032 | {"Connections", (char *)&show_thread_id_count, SHOW_FUNC, | ||
| 10033 | SHOW_SCOPE_GLOBAL}, | ||
| 10034 | {"Connection_errors_accept", (char *)&show_connection_errors_accept, | ||
| 10035 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10036 | {"Connection_errors_internal", (char *)&connection_errors_internal, | ||
| 10037 | SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10038 | {"Connection_errors_max_connections", | ||
| 10039 | (char *)&show_connection_errors_max_connection, SHOW_FUNC, | ||
| 10040 | SHOW_SCOPE_GLOBAL}, | ||
| 10041 | {"Connection_errors_peer_address", (char *)&connection_errors_peer_addr, | ||
| 10042 | SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10043 | {"Connection_errors_select", (char *)&show_connection_errors_query_block, | ||
| 10044 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10045 | {"Connection_errors_tcpwrap", (char *)&show_connection_errors_tcpwrap, | ||
| 10046 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10047 | {"Created_tmp_disk_tables", | ||
| 10048 | (char *)offsetof(System_status_var, created_tmp_disk_tables), | ||
| 10049 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10050 | {"Created_tmp_files", (char *)&my_tmp_file_created, SHOW_LONG, | ||
| 10051 | SHOW_SCOPE_GLOBAL}, | ||
| 10052 | {"Created_tmp_tables", | ||
| 10053 | (char *)offsetof(System_status_var, created_tmp_tables), | ||
| 10054 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10055 | {"Delayed_errors", (char *)&delayed_insert_errors, SHOW_LONG, | ||
| 10056 | SHOW_SCOPE_GLOBAL}, | ||
| 10057 | {"Delayed_insert_threads", (char *)&delayed_insert_threads, | ||
| 10058 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10059 | {"Delayed_writes", (char *)&delayed_insert_writes, SHOW_LONG, | ||
| 10060 | SHOW_SCOPE_GLOBAL}, | ||
| 10061 | {"Error_log_buffered_bytes", (char *)&log_sink_pfs_buffered_bytes, | ||
| 10062 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10063 | {"Error_log_buffered_events", (char *)&log_sink_pfs_buffered_events, | ||
| 10064 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10065 | {"Error_log_expired_events", (char *)&log_sink_pfs_expired_events, | ||
| 10066 | SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10067 | {"Error_log_latest_write", (char *)&log_sink_pfs_latest_timestamp, | ||
| 10068 | SHOW_LONGLONG, SHOW_SCOPE_GLOBAL}, | ||
| 10069 | {"Flush_commands", (char *)&refresh_version, SHOW_LONG_NOFLUSH, | ||
| 10070 | SHOW_SCOPE_GLOBAL}, | ||
| 10071 | {"Global_connection_memory", (char *)&show_global_mem_counter, SHOW_FUNC, | ||
| 10072 | SHOW_SCOPE_GLOBAL}, | ||
| 10073 | {"Handler_commit", (char *)offsetof(System_status_var, ha_commit_count), | ||
| 10074 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10075 | {"Handler_delete", (char *)offsetof(System_status_var, ha_delete_count), | ||
| 10076 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10077 | {"Handler_discover", (char *)offsetof(System_status_var, ha_discover_count), | ||
| 10078 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10079 | {"Handler_external_lock", | ||
| 10080 | (char *)offsetof(System_status_var, ha_external_lock_count), | ||
| 10081 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10082 | {"Handler_mrr_init", | ||
| 10083 | (char *)offsetof(System_status_var, ha_multi_range_read_init_count), | ||
| 10084 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10085 | {"Handler_prepare", (char *)offsetof(System_status_var, ha_prepare_count), | ||
| 10086 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10087 | {"Handler_read_first", | ||
| 10088 | (char *)offsetof(System_status_var, ha_read_first_count), | ||
| 10089 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10090 | {"Handler_read_key", (char *)offsetof(System_status_var, ha_read_key_count), | ||
| 10091 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10092 | {"Handler_read_last", | ||
| 10093 | (char *)offsetof(System_status_var, ha_read_last_count), | ||
| 10094 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10095 | {"Handler_read_next", | ||
| 10096 | (char *)offsetof(System_status_var, ha_read_next_count), | ||
| 10097 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10098 | {"Handler_read_prev", | ||
| 10099 | (char *)offsetof(System_status_var, ha_read_prev_count), | ||
| 10100 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10101 | {"Handler_read_rnd", (char *)offsetof(System_status_var, ha_read_rnd_count), | ||
| 10102 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10103 | {"Handler_read_rnd_next", | ||
| 10104 | (char *)offsetof(System_status_var, ha_read_rnd_next_count), | ||
| 10105 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10106 | {"Handler_rollback", (char *)offsetof(System_status_var, ha_rollback_count), | ||
| 10107 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10108 | {"Handler_savepoint", | ||
| 10109 | (char *)offsetof(System_status_var, ha_savepoint_count), | ||
| 10110 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10111 | {"Handler_savepoint_rollback", | ||
| 10112 | (char *)offsetof(System_status_var, ha_savepoint_rollback_count), | ||
| 10113 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10114 | {"Handler_update", (char *)offsetof(System_status_var, ha_update_count), | ||
| 10115 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10116 | {"Handler_write", (char *)offsetof(System_status_var, ha_write_count), | ||
| 10117 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10118 | {"Key_blocks_not_flushed", | ||
| 10119 | (char *)offsetof(KEY_CACHE, global_blocks_changed), SHOW_KEY_CACHE_LONG, | ||
| 10120 | SHOW_SCOPE_GLOBAL}, | ||
| 10121 | {"Key_blocks_unused", (char *)offsetof(KEY_CACHE, blocks_unused), | ||
| 10122 | SHOW_KEY_CACHE_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10123 | {"Key_blocks_used", (char *)offsetof(KEY_CACHE, blocks_used), | ||
| 10124 | SHOW_KEY_CACHE_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10125 | {"Key_read_requests", (char *)offsetof(KEY_CACHE, global_cache_r_requests), | ||
| 10126 | SHOW_KEY_CACHE_LONGLONG, SHOW_SCOPE_GLOBAL}, | ||
| 10127 | {"Key_reads", (char *)offsetof(KEY_CACHE, global_cache_read), | ||
| 10128 | SHOW_KEY_CACHE_LONGLONG, SHOW_SCOPE_GLOBAL}, | ||
| 10129 | {"Key_write_requests", (char *)offsetof(KEY_CACHE, global_cache_w_requests), | ||
| 10130 | SHOW_KEY_CACHE_LONGLONG, SHOW_SCOPE_GLOBAL}, | ||
| 10131 | {"Key_writes", (char *)offsetof(KEY_CACHE, global_cache_write), | ||
| 10132 | SHOW_KEY_CACHE_LONGLONG, SHOW_SCOPE_GLOBAL}, | ||
| 10133 | {"Last_query_cost", (char *)offsetof(System_status_var, last_query_cost), | ||
| 10134 | SHOW_DOUBLE_STATUS, SHOW_SCOPE_SESSION}, | ||
| 10135 | {"Last_query_partial_plans", | ||
| 10136 | (char *)offsetof(System_status_var, last_query_partial_plans), | ||
| 10137 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_SESSION}, | ||
| 10138 | {"Locked_connects", (char *)&locked_account_connection_count, SHOW_LONG, | ||
| 10139 | SHOW_SCOPE_GLOBAL}, | ||
| 10140 | {"Max_execution_time_exceeded", | ||
| 10141 | (char *)offsetof(System_status_var, max_execution_time_exceeded), | ||
| 10142 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10143 | {"Max_execution_time_set", | ||
| 10144 | (char *)offsetof(System_status_var, max_execution_time_set), | ||
| 10145 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10146 | {"Max_execution_time_set_failed", | ||
| 10147 | (char *)offsetof(System_status_var, max_execution_time_set_failed), | ||
| 10148 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10149 | {"Max_used_connections", | ||
| 10150 | (char *)&Connection_handler_manager::max_used_connections, SHOW_LONG, | ||
| 10151 | SHOW_SCOPE_GLOBAL}, | ||
| 10152 | {"Max_used_connections_time", (char *)&show_max_used_connections_time, | ||
| 10153 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10154 | {"Net_buffer_length", | ||
| 10155 | (char *)offsetof(System_status_var, net_buffer_length), | ||
| 10156 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10157 | {"Not_flushed_delayed_rows", (char *)&delayed_rows_in_use, | ||
| 10158 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10159 | {"Open_files", (char *)&my_file_opened, SHOW_LONG_NOFLUSH, | ||
| 10160 | SHOW_SCOPE_GLOBAL}, | ||
| 10161 | {"Open_streams", (char *)&my_stream_opened, SHOW_LONG_NOFLUSH, | ||
| 10162 | SHOW_SCOPE_GLOBAL}, | ||
| 10163 | {"Open_table_definitions", (char *)&show_table_definitions, SHOW_FUNC, | ||
| 10164 | SHOW_SCOPE_GLOBAL}, | ||
| 10165 | {"Open_tables", (char *)&show_open_tables, SHOW_FUNC, SHOW_SCOPE_ALL}, | ||
| 10166 | {"Opened_files", | ||
| 10167 | const_cast<char *>(reinterpret_cast<const char *>(&my_file_total_opened)), | ||
| 10168 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10169 | {"Opened_tables", (char *)offsetof(System_status_var, opened_tables), | ||
| 10170 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10171 | {"Opened_table_definitions", | ||
| 10172 | (char *)offsetof(System_status_var, opened_shares), SHOW_LONGLONG_STATUS, | ||
| 10173 | SHOW_SCOPE_ALL}, | ||
| 10174 | {"Prepared_stmt_count", (char *)&show_prepared_stmt_count, SHOW_FUNC, | ||
| 10175 | SHOW_SCOPE_GLOBAL}, | ||
| 10176 | {"Replica_open_temp_tables", (char *)&show_replica_open_temp_tables, | ||
| 10177 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10178 | #ifndef NDEBUG | ||
| 10179 | {"Replica_rows_last_search_algorithm_used", | ||
| 10180 | (char *)&show_replica_rows_last_search_algorithm_used, SHOW_FUNC, | ||
| 10181 | SHOW_SCOPE_GLOBAL}, | ||
| 10182 | #endif | ||
| 10183 | {"Queries", (char *)&show_queries, SHOW_FUNC, SHOW_SCOPE_ALL}, | ||
| 10184 | {"Questions", (char *)offsetof(System_status_var, questions), | ||
| 10185 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10186 | {"Secondary_engine_execution_count", | ||
| 10187 | (char *)offsetof(System_status_var, secondary_engine_execution_count), | ||
| 10188 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10189 | {"Select_full_join", | ||
| 10190 | (char *)offsetof(System_status_var, select_full_join_count), | ||
| 10191 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10192 | {"Select_full_range_join", | ||
| 10193 | (char *)offsetof(System_status_var, select_full_range_join_count), | ||
| 10194 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10195 | {"Select_range", (char *)offsetof(System_status_var, select_range_count), | ||
| 10196 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10197 | {"Select_range_check", | ||
| 10198 | (char *)offsetof(System_status_var, select_range_check_count), | ||
| 10199 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10200 | {"Select_scan", (char *)offsetof(System_status_var, select_scan_count), | ||
| 10201 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10202 | {"Slave_open_temp_tables", (char *)&show_replica_open_temp_tables, | ||
| 10203 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10204 | #ifndef NDEBUG | ||
| 10205 | {"Slave_rows_last_search_algorithm_used", | ||
| 10206 | (char *)&show_replica_rows_last_search_algorithm_used, SHOW_FUNC, | ||
| 10207 | SHOW_SCOPE_GLOBAL}, | ||
| 10208 | #endif | ||
| 10209 | {"Slow_launch_threads", | ||
| 10210 | (char *)&Per_thread_connection_handler::slow_launch_threads, SHOW_LONG, | ||
| 10211 | SHOW_SCOPE_ALL}, | ||
| 10212 | {"Slow_queries", (char *)offsetof(System_status_var, long_query_count), | ||
| 10213 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10214 | {"Sort_merge_passes", | ||
| 10215 | (char *)offsetof(System_status_var, filesort_merge_passes), | ||
| 10216 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10217 | {"Sort_range", (char *)offsetof(System_status_var, filesort_range_count), | ||
| 10218 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10219 | {"Sort_rows", (char *)offsetof(System_status_var, filesort_rows), | ||
| 10220 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10221 | {"Sort_scan", (char *)offsetof(System_status_var, filesort_scan_count), | ||
| 10222 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10223 | {"Ssl_accept_renegotiates", | ||
| 10224 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_accept_renegotiate, | ||
| 10225 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10226 | {"Ssl_accepts", (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_accept, | ||
| 10227 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10228 | {"Ssl_callback_cache_hits", | ||
| 10229 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_cb_hits, SHOW_FUNC, | ||
| 10230 | SHOW_SCOPE_GLOBAL}, | ||
| 10231 | {"Ssl_cipher", (char *)&show_ssl_get_cipher, SHOW_FUNC, SHOW_SCOPE_ALL}, | ||
| 10232 | {"Ssl_cipher_list", (char *)&show_ssl_get_cipher_list, SHOW_FUNC, | ||
| 10233 | SHOW_SCOPE_ALL}, | ||
| 10234 | {"Ssl_client_connects", | ||
| 10235 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_connect, SHOW_FUNC, | ||
| 10236 | SHOW_SCOPE_GLOBAL}, | ||
| 10237 | {"Ssl_connect_renegotiates", | ||
| 10238 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_connect_renegotiate, | ||
| 10239 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10240 | {"Ssl_ctx_verify_depth", | ||
| 10241 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_get_verify_depth, SHOW_FUNC, | ||
| 10242 | SHOW_SCOPE_GLOBAL}, | ||
| 10243 | {"Ssl_ctx_verify_mode", | ||
| 10244 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_get_verify_mode, SHOW_FUNC, | ||
| 10245 | SHOW_SCOPE_GLOBAL}, | ||
| 10246 | {"Ssl_default_timeout", (char *)&show_ssl_get_default_timeout, SHOW_FUNC, | ||
| 10247 | SHOW_SCOPE_ALL}, | ||
| 10248 | {"Ssl_finished_accepts", | ||
| 10249 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_accept_good, SHOW_FUNC, | ||
| 10250 | SHOW_SCOPE_GLOBAL}, | ||
| 10251 | {"Ssl_finished_connects", | ||
| 10252 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_connect_good, SHOW_FUNC, | ||
| 10253 | SHOW_SCOPE_GLOBAL}, | ||
| 10254 | {"Ssl_session_cache_hits", | ||
| 10255 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_hits, SHOW_FUNC, | ||
| 10256 | SHOW_SCOPE_GLOBAL}, | ||
| 10257 | {"Ssl_session_cache_misses", | ||
| 10258 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_misses, SHOW_FUNC, | ||
| 10259 | SHOW_SCOPE_GLOBAL}, | ||
| 10260 | {"Ssl_session_cache_mode", | ||
| 10261 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_get_session_cache_mode, | ||
| 10262 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10263 | {"Ssl_session_cache_overflows", | ||
| 10264 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_cache_full, SHOW_FUNC, | ||
| 10265 | SHOW_SCOPE_GLOBAL}, | ||
| 10266 | {"Ssl_session_cache_size", | ||
| 10267 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_get_cache_size, | ||
| 10268 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10269 | {"Ssl_session_cache_timeouts", | ||
| 10270 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_timeouts, SHOW_FUNC, | ||
| 10271 | SHOW_SCOPE_GLOBAL}, | ||
| 10272 | {"Ssl_sessions_reused", (char *)&show_ssl_session_reused, SHOW_FUNC, | ||
| 10273 | SHOW_SCOPE_ALL}, | ||
| 10274 | {"Ssl_used_session_cache_entries", | ||
| 10275 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_number, SHOW_FUNC, | ||
| 10276 | SHOW_SCOPE_GLOBAL}, | ||
| 10277 | {"Ssl_verify_depth", (char *)&show_ssl_get_verify_depth, SHOW_FUNC, | ||
| 10278 | SHOW_SCOPE_ALL}, | ||
| 10279 | {"Ssl_verify_mode", (char *)&show_ssl_get_verify_mode, SHOW_FUNC, | ||
| 10280 | SHOW_SCOPE_ALL}, | ||
| 10281 | {"Ssl_version", (char *)&show_ssl_get_version, SHOW_FUNC, SHOW_SCOPE_ALL}, | ||
| 10282 | {"Ssl_server_not_before", | ||
| 10283 | (char *)&Ssl_mysql_main_status::show_ssl_get_server_not_before, SHOW_FUNC, | ||
| 10284 | SHOW_SCOPE_ALL}, | ||
| 10285 | {"Ssl_server_not_after", | ||
| 10286 | (char *)&Ssl_mysql_main_status::show_ssl_get_server_not_after, SHOW_FUNC, | ||
| 10287 | SHOW_SCOPE_ALL}, | ||
| 10288 | {"Current_tls_ca", (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_ca, | ||
| 10289 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10290 | {"Current_tls_capath", | ||
| 10291 | (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_capath, SHOW_FUNC, | ||
| 10292 | SHOW_SCOPE_GLOBAL}, | ||
| 10293 | {"Current_tls_cert", (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_cert, | ||
| 10294 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10295 | {"Current_tls_key", (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_key, | ||
| 10296 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10297 | {"Current_tls_version", | ||
| 10298 | (char *)&Ssl_mysql_main_status::show_ssl_get_tls_version, SHOW_FUNC, | ||
| 10299 | SHOW_SCOPE_GLOBAL}, | ||
| 10300 | {"Current_tls_cipher", | ||
| 10301 | (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_cipher, SHOW_FUNC, | ||
| 10302 | SHOW_SCOPE_GLOBAL}, | ||
| 10303 | {"Current_tls_ciphersuites", | ||
| 10304 | (char *)&Ssl_mysql_main_status::show_ssl_get_tls_ciphersuites, SHOW_FUNC, | ||
| 10305 | SHOW_SCOPE_GLOBAL}, | ||
| 10306 | {"Current_tls_crl", (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_crl, | ||
| 10307 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10308 | {"Current_tls_crlpath", | ||
| 10309 | (char *)&Ssl_mysql_main_status::show_ssl_get_ssl_crlpath, SHOW_FUNC, | ||
| 10310 | SHOW_SCOPE_GLOBAL}, | ||
| 10311 | {"Rsa_public_key", (char *)&show_rsa_public_key, SHOW_FUNC, | ||
| 10312 | SHOW_SCOPE_GLOBAL}, | ||
| 10313 | {"Table_locks_immediate", (char *)&locks_immediate, SHOW_LONG, | ||
| 10314 | SHOW_SCOPE_GLOBAL}, | ||
| 10315 | {"Table_locks_waited", (char *)&locks_waited, SHOW_LONG, SHOW_SCOPE_GLOBAL}, | ||
| 10316 | {"Table_open_cache_hits", | ||
| 10317 | (char *)offsetof(System_status_var, table_open_cache_hits), | ||
| 10318 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10319 | {"Table_open_cache_misses", | ||
| 10320 | (char *)offsetof(System_status_var, table_open_cache_misses), | ||
| 10321 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10322 | {"Table_open_cache_overflows", | ||
| 10323 | (char *)offsetof(System_status_var, table_open_cache_overflows), | ||
| 10324 | SHOW_LONGLONG_STATUS, SHOW_SCOPE_ALL}, | ||
| 10325 | {"Tc_log_max_pages_used", (char *)&tc_log_max_pages_used, SHOW_LONG, | ||
| 10326 | SHOW_SCOPE_GLOBAL}, | ||
| 10327 | {"Tc_log_page_size", (char *)&tc_log_page_size, SHOW_LONG_NOFLUSH, | ||
| 10328 | SHOW_SCOPE_GLOBAL}, | ||
| 10329 | {"Tc_log_page_waits", (char *)&tc_log_page_waits, SHOW_LONG, | ||
| 10330 | SHOW_SCOPE_GLOBAL}, | ||
| 10331 | #ifdef HAVE_POOL_OF_THREADS | ||
| 10332 | {"Threadpool_idle_threads", (char *)&show_threadpool_idle_threads, | ||
| 10333 | SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10334 | {"Threadpool_threads", (char *)&tp_stats.num_worker_threads, SHOW_INT, | ||
| 10335 | SHOW_SCOPE_GLOBAL}, | ||
| 10336 | #endif | ||
| 10337 | {"Threads_cached", | ||
| 10338 | (char *)&Per_thread_connection_handler::blocked_pthread_count, | ||
| 10339 | SHOW_LONG_NOFLUSH, SHOW_SCOPE_GLOBAL}, | ||
| 10340 | {"Threads_connected", (char *)&Connection_handler_manager::connection_count, | ||
| 10341 | SHOW_INT, SHOW_SCOPE_GLOBAL}, | ||
| 10342 | {"Threads_created", (char *)&show_num_thread_created, SHOW_FUNC, | ||
| 10343 | SHOW_SCOPE_GLOBAL}, | ||
| 10344 | {"Threads_running", (char *)&show_num_thread_running, SHOW_FUNC, | ||
| 10345 | SHOW_SCOPE_GLOBAL}, | ||
| 10346 | {"Uptime", (char *)&show_starttime, SHOW_FUNC, SHOW_SCOPE_GLOBAL}, | ||
| 10347 | #ifdef ENABLED_PROFILING | ||
| 10348 | {"Uptime_since_flush_status", (char *)&show_flushstatustime, SHOW_FUNC, | ||
| 10349 | 36374 | SHOW_SCOPE_GLOBAL}, | |
| 10350 | 36374 | #endif | |
| 10351 | {"Ssl_session_cache_timeout", | ||
| 10352 | (char *)&Ssl_mysql_main_status::show_ssl_ctx_sess_timeout, SHOW_FUNC, | ||
| 10353 |
1/2✓ Branch 0 taken 36374 times.
✗ Branch 1 not taken.
|
36374 | SHOW_SCOPE_GLOBAL}, |
| 10354 | 36374 | {"Tls_library_version", (char *)&show_tls_library_version, SHOW_FUNC, | |
| 10355 | SHOW_SCOPE_GLOBAL}, | ||
| 10356 | 14 | {NullS, NullS, SHOW_LONG, SHOW_SCOPE_ALL}}; | |
| 10357 | 14 | ||
| 10358 | void add_terminator(vector<my_option> *options) { | ||
| 10359 | 14 | my_option empty_element = {nullptr, 0, nullptr, nullptr, nullptr, | |
| 10360 | 14 | nullptr, GET_NO_ARG, NO_ARG, 0, 0, | |
| 10361 | 0, nullptr, 0, nullptr}; | ||
| 10362 | options->push_back(empty_element); | ||
| 10363 | 123458 | } | |
| 10364 | 123458 | ||
| 10365 | 123458 | static void print_server_version(void) { | |
| 10366 |
3/4✓ Branch 0 taken 653154 times.
✓ Branch 1 taken 792 times.
✓ Branch 2 taken 792 times.
✗ Branch 3 not taken.
|
653946 | set_server_version(); |
| 10367 |
2/2✓ Branch 0 taken 79370 times.
✓ Branch 1 taken 574576 times.
|
653946 | |
| 10368 |
4/4✓ Branch 0 taken 1514 times.
✓ Branch 1 taken 77856 times.
✓ Branch 2 taken 1220 times.
✓ Branch 3 taken 294 times.
|
79370 | print_explicit_version(server_version); |
| 10369 | 1220 | } | |
| 10370 | |||
| 10371 | 78150 | /** Compares two options' names, treats - and _ the same */ | |
| 10372 | static bool operator<(const my_option &a, const my_option &b) { | ||
| 10373 |
2/2✓ Branch 0 taken 46282 times.
✓ Branch 1 taken 528294 times.
|
574576 | const char *sa = a.name; |
| 10374 |
4/4✓ Branch 0 taken 1318 times.
✓ Branch 1 taken 44964 times.
✓ Branch 2 taken 974 times.
✓ Branch 3 taken 344 times.
|
46282 | const char *sb = b.name; |
| 10375 | 974 | for (; *sa || *sb; sa++, sb++) { | |
| 10376 | if (*sa < *sb) { | ||
| 10377 | 45308 | if (*sa == '-' && *sb == '_') | |
| 10378 | continue; | ||
| 10379 | else | ||
| 10380 | ✗ | return true; | |
| 10381 | ✗ | } | |
| 10382 | if (*sa > *sb) { | ||
| 10383 | if (*sa == '_' && *sb == '-') | ||
| 10384 | 14 | continue; | |
| 10385 | 14 | else | |
| 10386 | return false; | ||
| 10387 | 14 | } | |
| 10388 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | } |
| 10389 |
2/2✓ Branch 0 taken 294 times.
✓ Branch 1 taken 14 times.
|
308 | assert(a.name == b.name); |
| 10390 |
1/2✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
|
294 | return false; |
| 10391 | } | ||
| 10392 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | |
| 10393 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | static void print_help() { |
| 10394 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | MEM_ROOT mem_root(key_memory_help, 4096); |
| 10395 | |||
| 10396 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | all_options.pop_back(); |
| 10397 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | sys_var_add_options(&all_options, sys_var::PARSE_EARLY); |
| 10398 | for (my_option *opt = my_long_early_options; opt->name != nullptr; opt++) { | ||
| 10399 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | all_options.push_back(*opt); |
| 10400 | 14 | } | |
| 10401 | 14 | add_plugin_options(&all_options, &mem_root); | |
| 10402 | std::sort(all_options.begin(), all_options.end(), std::less<my_option>()); | ||
| 10403 | 14 | add_terminator(&all_options); | |
| 10404 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | |
| 10405 |
2/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 14 times.
|
14 | my_print_help(&all_options[0]); |
| 10406 | my_print_variables(&all_options[0]); | ||
| 10407 | ✗ | ||
| 10408 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | mem_root.Clear(); |
| 10409 | ✗ | vector<my_option>().swap(all_options); // Deletes the vector contents. | |
| 10410 |
2/6✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 14 times.
✗ Branch 5 not taken.
|
14 | } |
| 10411 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | |
| 10412 | static void usage(void) { | ||
| 10413 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | DBUG_TRACE; |
| 10414 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if (!(default_charset_info = get_charset_by_csname( |
| 10415 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | default_character_set_name, MY_CS_PRIMARY, MYF(MY_WME)))) |
| 10416 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | exit(MYSQLD_ABORT_EXIT); |
| 10417 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
|
14 | if (!default_collation_name) |
| 10418 | ✗ | default_collation_name = default_charset_info->m_coll_name; | |
| 10419 | if (is_help_or_validate_option() || opt_verbose) { | ||
| 10420 | my_progname = my_progname + dirname_length(my_progname); | ||
| 10421 | } | ||
| 10422 | print_server_version(); | ||
| 10423 | puts(ORACLE_WELCOME_COPYRIGHT_NOTICE("2000")); | ||
| 10424 | puts("Starts the MySQL database server.\n"); | ||
| 10425 | printf("Usage: %s [OPTIONS]\n", my_progname); | ||
| 10426 | if (!opt_verbose) | ||
| 10427 | puts( | ||
| 10428 | "\nFor more help options (several pages), use mysqld --verbose " | ||
| 10429 | "--help."); | ||
| 10430 | else { | ||
| 10431 | #ifdef _WIN32 | ||
| 10432 | puts( | ||
| 10433 | "NT and Win32 specific options:\n\ | ||
| 10434 | --install Install the default service (NT).\n\ | ||
| 10435 | --install-manual Install the default service started manually (NT).\n\ | ||
| 10436 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | --install service_name Install an optional service (NT).\n\ |
| 10437 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | --install-manual service_name Install an optional service started manually (NT).\n\ |
| 10438 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | --remove Remove the default service from the service list (NT).\n\ |
| 10439 | --remove service_name Remove the service_name from the service list (NT).\n\ | ||
| 10440 | --enable-named-pipe Only to be used for the default server (NT).\n\ | ||
| 10441 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | --standalone Dummy option to start as a standalone server (NT).\ |
| 10442 | "); | ||
| 10443 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
|
14 | puts(""); |
| 10444 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | #endif |
| 10445 | print_defaults(MYSQL_CONFIG_NAME, load_default_groups); | ||
| 10446 | puts(""); | ||
| 10447 | set_ports(); | ||
| 10448 | |||
| 10449 | /* Print out all the options including plugin supplied options */ | ||
| 10450 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | print_help(); |
| 10451 | |||
| 10452 | if (!dynamic_plugins_are_initialized) { | ||
| 10453 | puts( | ||
| 10454 | "\n\ | ||
| 10455 | 14 | Plugins have parameters that are not reflected in this list\n\ | |
| 10456 | because execution stopped before plugins were initialized."); | ||
| 10457 | } | ||
| 10458 | |||
| 10459 | puts( | ||
| 10460 | "\n\ | ||
| 10461 | To see what values a running MySQL server is using, type\n\ | ||
| 10462 | 'mysqladmin variables' instead of 'mysqld --verbose --help'."); | ||
| 10463 | } | ||
| 10464 | } | ||
| 10465 | |||
| 10466 | /** | ||
| 10467 | Initialize MySQL global variables to default values. | ||
| 10468 | |||
| 10469 | 12142 | @note | |
| 10470 | The reason to set a lot of global variables to zero is that | ||
| 10471 | 12142 | on some exotic platforms global variables are | |
| 10472 | 12142 | not set to 0 when a program starts. | |
| 10473 | 12142 | ||
| 10474 | 12142 | We don't need to set variables referred to in my_long_options | |
| 10475 | 12142 | as these are initialized by my_getopt. | |
| 10476 | 12142 | */ | |
| 10477 | 12142 | ||
| 10478 | 12142 | static int mysql_init_variables() { | |
| 10479 | 12142 | /* Things reset to zero */ | |
| 10480 | 12142 | opt_skip_replica_start = false; | |
| 10481 | 12142 | pidfile_name[0] = 0; | |
| 10482 | 12142 | myisam_test_invalid_symlink = test_if_data_home_dir; | |
| 10483 | 12142 | opt_general_log = opt_slow_log = false; | |
| 10484 | 12142 | opt_disable_networking = opt_skip_show_db = false; | |
| 10485 | 12142 | opt_skip_name_resolve = false; | |
| 10486 | 12142 | opt_general_logname = opt_binlog_index_name = opt_slow_logname = nullptr; | |
| 10487 | 12142 | opt_tc_log_file = "tc.log"; // no hostname in tc_log file name ! | |
| 10488 | 12142 | opt_myisam_log = false; | |
| 10489 | 12142 | mqh_used = false; | |
| 10490 | 12142 | cleanup_done = 0; | |
| 10491 | 12142 | server_id_supplied = false; | |
| 10492 | 12142 | select_errors = ha_open_options = 0; | |
| 10493 | 12142 | atomic_replica_open_temp_tables = 0; | |
| 10494 | 12142 | opt_endinfo = using_udf_functions = false; | |
| 10495 | 12142 | opt_using_transactions = false; | |
| 10496 | 12142 | set_connection_events_loop_aborted(false); | |
| 10497 | 12142 | set_mysqld_offline_mode(false); | |
| 10498 | 12142 | set_mysqld_partial_revokes(opt_partial_revokes); | |
| 10499 | 12142 | server_operational_state = SERVER_BOOTING; | |
| 10500 | 12142 | aborted_threads = 0; | |
| 10501 | 12142 | delayed_insert_threads = delayed_insert_writes = delayed_rows_in_use = 0; | |
| 10502 | 12142 | delayed_insert_errors = 0; | |
| 10503 | specialflag = 0; | ||
| 10504 | 12142 | binlog_cache_use = binlog_cache_disk_use = 0; | |
| 10505 | mysqld_user = mysqld_chroot = opt_init_file = opt_bin_logname = nullptr; | ||
| 10506 | 12142 | prepared_stmt_count = 0; | |
| 10507 | mysqld_unix_port = opt_mysql_tmpdir = my_bind_addr_str = NullS; | ||
| 10508 | new (&mysql_tmpdir_list) MY_TMPDIR; | ||
| 10509 | 12142 | memset(&global_status_var, 0, sizeof(global_status_var)); | |
| 10510 | 12142 | opt_large_pages = false; | |
| 10511 | 12142 | opt_super_large_pages = false; | |
| 10512 | 12142 | #if defined(ENABLED_DEBUG_SYNC) | |
| 10513 | 12142 | opt_debug_sync_timeout = 0; | |
| 10514 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 10515 | 12142 | server_uuid[0] = 0; | |
| 10516 | 12142 | ||
| 10517 | 12142 | /* Character sets */ | |
| 10518 | 12142 | system_charset_info = &my_charset_utf8_general_ci; | |
| 10519 | 12142 | files_charset_info = &my_charset_utf8_general_ci; | |
| 10520 | 12142 | national_charset_info = &my_charset_utf8_general_ci; | |
| 10521 | 12142 | table_alias_charset = &my_charset_bin; | |
| 10522 | 12142 | character_set_filesystem = &my_charset_bin; | |
| 10523 |
2/4✓ Branch 0 taken 12142 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12142 times.
|
12142 | |
| 10524 | 12142 | opt_specialflag = 0; | |
| 10525 | ✗ | pidfile_name_ptr = pidfile_name; | |
| 10526 | ✗ | lc_messages_dir_ptr = lc_messages_dir; | |
| 10527 | protocol_version = PROTOCOL_VERSION; | ||
| 10528 | what_to_log = ~(1L << (uint)COM_TIME); | ||
| 10529 | 12142 | refresh_version = 1L; /* Increments on each reload */ | |
| 10530 | my_stpcpy(server_version, MYSQL_SERVER_VERSION); | ||
| 10531 | key_caches.clear(); | ||
| 10532 | 12142 | if (!(dflt_key_cache = get_or_create_key_cache(std::string_view{ | |
| 10533 | 12142 | default_key_cache_base.str, default_key_cache_base.length}))) { | |
| 10534 | 12142 | LogErr(ERROR_LEVEL, ER_KEYCACHE_OOM); | |
| 10535 | 12142 | return 1; | |
| 10536 | 12142 | } | |
| 10537 | 12142 | /* set key_cache_hash.default_value = dflt_key_cache */ | |
| 10538 | 12142 | multi_keycache_init(); | |
| 10539 | 12142 | ||
| 10540 | /* Replication parameters */ | ||
| 10541 | master_info_file = "master.info"; | ||
| 10542 | 12142 | relay_log_info_file = "relay-log.info"; | |
| 10543 | report_user = report_password = report_host = nullptr; /* TO BE DELETED */ | ||
| 10544 | 12142 | opt_relay_logname = opt_relaylog_index_name = nullptr; | |
| 10545 | 12142 | opt_relaylog_index_name_supplied = false; | |
| 10546 | 12142 | opt_relay_logname_supplied = false; | |
| 10547 | 12142 | log_bin_basename = nullptr; | |
| 10548 | 12142 | log_bin_index = nullptr; | |
| 10549 | 12142 | ||
| 10550 | 12142 | /* Handler variables */ | |
| 10551 | 12142 | total_ha_2pc = 0; | |
| 10552 | /* Variables in libraries */ | ||
| 10553 | charsets_dir = nullptr; | ||
| 10554 | default_character_set_name = MYSQL_DEFAULT_CHARSET_NAME; | ||
| 10555 | 12142 | default_collation_name = compiled_default_collation_name; | |
| 10556 | character_set_filesystem_name = "binary"; | ||
| 10557 | lc_messages = mysqld_default_locale_name; | ||
| 10558 | lc_time_names_name = mysqld_default_locale_name; | ||
| 10559 | 12142 | opt_replication_optimize_for_static_plugin_config = false; | |
| 10560 | opt_replication_sender_observe_commit_only = false; | ||
| 10561 | |||
| 10562 | /* Variables that depends on compile options */ | ||
| 10563 | #ifndef NDEBUG | ||
| 10564 | 12142 | default_dbug_option = | |
| 10565 | IF_WIN("d:t:i:O,\\mysqld.trace", "d:t:i:o,/tmp/mysqld.trace"); | ||
| 10566 | 12142 | #endif | |
| 10567 | #ifdef ENABLED_PROFILING | ||
| 10568 | 12142 | have_profiling = SHOW_OPTION_YES; | |
| 10569 | #else | ||
| 10570 | 12142 | have_profiling = SHOW_OPTION_NO; | |
| 10571 | #endif | ||
| 10572 | 12142 | ||
| 10573 | have_symlink = SHOW_OPTION_YES; | ||
| 10574 | |||
| 10575 | 12142 | have_dlopen = SHOW_OPTION_YES; | |
| 10576 | |||
| 10577 | have_query_cache = SHOW_OPTION_NO; | ||
| 10578 | |||
| 10579 | have_geometry = SHOW_OPTION_YES; | ||
| 10580 | 12142 | ||
| 10581 | 12142 | have_rtree_keys = SHOW_OPTION_YES; | |
| 10582 | 12142 | ||
| 10583 | /* Always true */ | ||
| 10584 | 12142 | have_compress = SHOW_OPTION_YES; | |
| 10585 | #if defined(_WIN32) | ||
| 10586 | shared_memory_base_name = default_shared_memory_base_name; | ||
| 10587 | #endif | ||
| 10588 | |||
| 10589 | have_backup_locks = SHOW_OPTION_YES; | ||
| 10590 | have_backup_safe_binlog_info = SHOW_OPTION_YES; | ||
| 10591 | have_snapshot_cloning = SHOW_OPTION_YES; | ||
| 10592 | |||
| 10593 | return 0; | ||
| 10594 | } | ||
| 10595 | |||
| 10596 | /** | ||
| 10597 | 363 | Check if it is a global replication filter setting. | |
| 10598 |
1/2✓ Branch 0 taken 363 times.
✗ Branch 1 not taken.
|
363 | |
| 10599 | @param argument The setting of startup option --replicate-*. | ||
| 10600 | 363 | ||
| 10601 | 363 | @retval | |
| 10602 |
2/2✓ Branch 0 taken 267 times.
✓ Branch 1 taken 96 times.
|
363 | 0 OK |
| 10603 | @retval | ||
| 10604 | 363 | 1 Error | |
| 10605 | 363 | */ | |
| 10606 | static bool is_rpl_global_filter_setting(char *argument) { | ||
| 10607 | DBUG_TRACE; | ||
| 10608 | |||
| 10609 | bool res = false; | ||
| 10610 | char *p = strchr(argument, ':'); | ||
| 10611 | if (p == nullptr) res = true; | ||
| 10612 | |||
| 10613 | return res; | ||
| 10614 | 96 | } | |
| 10615 |
1/2✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
|
96 | |
| 10616 | /** | ||
| 10617 | 96 | Extract channel name and filter value from argument. | |
| 10618 | |||
| 10619 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
|
96 | @param [out] channel_name The name of the channel. |
| 10620 | @param [out] filter_val The value of filter. | ||
| 10621 | @param argument The setting of startup option --replicate-*. | ||
| 10622 | */ | ||
| 10623 | void parse_filter_arg(char **channel_name, char **filter_val, char *argument) { | ||
| 10624 | DBUG_TRACE; | ||
| 10625 | |||
| 10626 | 96 | char *p = strchr(argument, ':'); | |
| 10627 | 96 | ||
| 10628 | 96 | assert(p != nullptr); | |
| 10629 | 96 | ||
| 10630 | /* | ||
| 10631 | If argument='channel_1:db1', then channel_name='channel_1' | ||
| 10632 | and filter_val='db1'; If argument=':db1', then channel_name='' | ||
| 10633 | and filter_val='db1'. | ||
| 10634 | */ | ||
| 10635 | *channel_name = argument; | ||
| 10636 | *filter_val = p + 1; | ||
| 10637 | *p = 0; | ||
| 10638 | } | ||
| 10639 | |||
| 10640 | /** | ||
| 10641 | Extract channel name and filter value from argument. | ||
| 10642 | |||
| 10643 | 54 | @param [out] key The db is rewritten from. | |
| 10644 |
1/2✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
|
54 | @param [out] val The db is rewritten to. |
| 10645 | @param argument The value of filter. | ||
| 10646 | 54 | ||
| 10647 | @retval | ||
| 10648 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 46 times.
|
54 | 0 OK |
| 10649 |
8/16✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 8 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 8 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 8 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8 times.
✗ Branch 15 not taken.
|
8 | @retval |
| 10650 | 8 | 1 Error | |
| 10651 | */ | ||
| 10652 | 46 | static int parse_replicate_rewrite_db(char **key, char **val, char *argument) { | |
| 10653 | DBUG_TRACE; | ||
| 10654 |
3/4✓ Branch 0 taken 44 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 44 times.
|
46 | char *p; |
| 10655 | 46 | *key = argument; | |
| 10656 | |||
| 10657 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 44 times.
|
46 | if (!(p = strstr(argument, "->"))) { |
| 10658 |
8/16✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
|
2 | LogErr(ERROR_LEVEL, ER_RPL_REWRITEDB_MISSING_ARROW); |
| 10659 | 2 | return 1; | |
| 10660 | } | ||
| 10661 |
4/4✓ Branch 0 taken 42 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 39 times.
|
47 | *val = p + 2; |
| 10662 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 39 times.
|
44 | |
| 10663 |
8/16✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 5 times.
✗ Branch 15 not taken.
|
5 | while (p > argument && my_isspace(mysqld_charset, p[-1])) p--; |
| 10664 | 5 | *p = 0; | |
| 10665 | |||
| 10666 | if (!**key) { | ||
| 10667 | 39 | LogErr(ERROR_LEVEL, ER_RPL_REWRITEDB_EMPTY_FROM); | |
| 10668 | 54 | return 1; | |
| 10669 | } | ||
| 10670 | 704239 | while (**val && my_isspace(mysqld_charset, **val)) (*val)++; | |
| 10671 | if (!**val) { | ||
| 10672 | LogErr(ERROR_LEVEL, ER_RPL_REWRITEDB_EMPTY_TO); | ||
| 10673 | 704239 | return 1; | |
| 10674 | } | ||
| 10675 | |||
| 10676 | return 0; | ||
| 10677 |
1/2✓ Branch 0 taken 704239 times.
✗ Branch 1 not taken.
|
704239 | } |
| 10678 |
4/4✓ Branch 0 taken 472685 times.
✓ Branch 1 taken 231554 times.
✓ Branch 2 taken 7864 times.
✓ Branch 3 taken 464821 times.
|
704239 | |
| 10679 |
2/2✓ Branch 0 taken 163 times.
✓ Branch 1 taken 7701 times.
|
7864 | bool mysqld_get_one_option(int optid, |
| 10680 | const struct my_option *opt [[maybe_unused]], | ||
| 10681 | char *argument) { | ||
| 10682 | Rpl_filter *rpl_filter = nullptr; | ||
| 10683 | char *filter_val; | ||
| 10684 | char *channel_name; | ||
| 10685 | |||
| 10686 | auto *sysvar = intern_find_sys_var(opt->name, strlen(opt->name)); | ||
| 10687 | if (sysvar && sysvar->m_persisted_alias && | ||
| 10688 | sysvar->m_is_persisted_deprecated) { | ||
| 10689 | /* | ||
| 10690 | At this point, my_handle_options (through setval and | ||
| 10691 | 163 | setval_source) has set the source for itself. It was set using | |
| 10692 |
1/2✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
|
163 | direct access to the my_option object, so it is really the |
| 10693 |
1/2✓ Branch 0 taken 163 times.
✗ Branch 1 not taken.
|
163 | source object that is a member of this sysvar that has been set. |
| 10694 |
2/2✓ Branch 0 taken 124 times.
✓ Branch 1 taken 39 times.
|
163 | In case this is a deprecated alias, that does not help, because |
| 10695 | the high-level getters and setters will get and set the value in | ||
| 10696 | the base variable, not the alias. Therefore, we copy the source | ||
| 10697 | from the alias to the base variable, using a low-level getter in | ||
| 10698 | the alias and a high-level setter in the alias. | ||
| 10699 | */ | ||
| 10700 | auto *source = sysvar->get_option()->arg_source; | ||
| 10701 | sysvar->set_source(source->m_source); | ||
| 10702 | 124 | sysvar->set_source_name(source->m_path_name); | |
| 10703 |
2/4✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 124 times.
✗ Branch 3 not taken.
|
124 | if (source->m_source != PERSISTED) { |
| 10704 | /* | ||
| 10705 | Generate the deprecation warning. But not if we are loading | ||
| 10706 | it from the persisted variables file (i.e., this is a variable | ||
| 10707 |
62/74✓ Branch 0 taken 268 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 31 times.
✓ Branch 4 taken 12713 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 3 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 233 times.
✓ Branch 9 taken 1 times.
✓ Branch 10 taken 3280 times.
✓ Branch 11 taken 2 times.
✓ Branch 12 taken 22 times.
✓ Branch 13 taken 22 times.
✓ Branch 14 taken 35019 times.
✓ Branch 15 taken 29 times.
✓ Branch 16 taken 4 times.
✓ Branch 17 taken 146 times.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
✗ Branch 22 not taken.
✓ Branch 23 taken 4772 times.
✓ Branch 24 taken 12 times.
✓ Branch 25 taken 34 times.
✓ Branch 26 taken 63 times.
✓ Branch 27 taken 54 times.
✓ Branch 28 taken 18 times.
✓ Branch 29 taken 8 times.
✓ Branch 30 taken 59 times.
✓ Branch 31 taken 27 times.
✓ Branch 32 taken 40 times.
✓ Branch 33 taken 86 times.
✓ Branch 34 taken 3254 times.
✗ Branch 35 not taken.
✓ Branch 36 taken 1 times.
✓ Branch 37 taken 41 times.
✓ Branch 38 taken 11596 times.
✓ Branch 39 taken 5 times.
✓ Branch 40 taken 18 times.
✓ Branch 41 taken 11752 times.
✓ Branch 42 taken 337 times.
✓ Branch 43 taken 11436 times.
✓ Branch 44 taken 865 times.
✓ Branch 45 taken 1501 times.
✓ Branch 46 taken 2271 times.
✓ Branch 47 taken 926 times.
✓ Branch 48 taken 11675 times.
✓ Branch 49 taken 2 times.
✓ Branch 50 taken 2 times.
✓ Branch 51 taken 2 times.
✓ Branch 52 taken 7 times.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✗ Branch 56 not taken.
✓ Branch 57 taken 370 times.
✓ Branch 58 taken 137 times.
✓ Branch 59 taken 2782 times.
✗ Branch 60 not taken.
✓ Branch 61 taken 4 times.
✓ Branch 62 taken 5 times.
✓ Branch 63 taken 2 times.
✓ Branch 64 taken 1 times.
✓ Branch 65 taken 57 times.
✓ Branch 66 taken 260 times.
✓ Branch 67 taken 100 times.
✓ Branch 68 taken 1 times.
✓ Branch 69 taken 1 times.
✓ Branch 70 taken 103 times.
✓ Branch 71 taken 188 times.
✓ Branch 72 taken 1 times.
✓ Branch 73 taken 587339 times.
|
704239 | having the PERSIST_AS_READONLY flag set): in that case a more |
| 10708 | 268 | specific warning was already generated when loading the | |
| 10709 | persisted variable. | ||
| 10710 |
2/4✓ Branch 0 taken 268 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 268 times.
✗ Branch 3 not taken.
|
268 | */ |
| 10711 | const char *ds = sysvar->get_deprecation_substitute(); | ||
| 10712 | 268 | if (ds) push_deprecated_warn(nullptr, opt->name, ds); | |
| 10713 | 268 | } | |
| 10714 | 2 | } | |
| 10715 | 2 | ||
| 10716 | 2 | switch (optid) { | |
| 10717 | 2 | case '#': | |
| 10718 | 248 | #ifndef NDEBUG | |
| 10719 |
1/2✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
|
248 | DBUG_SET_INITIAL(argument ? argument : default_dbug_option); |
| 10720 | 248 | #endif | |
| 10721 | 248 | opt_endinfo = true; /* unireg: memory allocation */ | |
| 10722 | 31 | break; | |
| 10723 |
2/2✓ Branch 0 taken 30 times.
✓ Branch 1 taken 1 times.
|
31 | case 'a': |
| 10724 | 30 | global_system_variables.sql_mode = MODE_ANSI; | |
| 10725 | 31 | global_system_variables.transaction_isolation = ISO_SERIALIZABLE; | |
| 10726 | 12713 | break; | |
| 10727 |
1/2✓ Branch 0 taken 12713 times.
✗ Branch 1 not taken.
|
12713 | case 'b': |
| 10728 | strmake(mysql_home, argument, sizeof(mysql_home) - 1); | ||
| 10729 | 12713 | mysql_home_ptr = mysql_home; | |
| 10730 | 12713 | break; | |
| 10731 | ✗ | case 'C': | |
| 10732 | ✗ | if (default_collation_name == compiled_default_collation_name) | |
| 10733 | ✗ | default_collation_name = nullptr; | |
| 10734 | break; | ||
| 10735 | ✗ | case 'h': | |
| 10736 | ✗ | strmake(mysql_real_data_home, argument, sizeof(mysql_real_data_home) - 1); | |
| 10737 | 3 | /* Correct pointer set by my_getopt */ | |
| 10738 |
3/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 2 times.
|
3 | mysql_real_data_home_ptr = mysql_real_data_home; |
| 10739 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | break; |
| 10740 | case 'u': | ||
| 10741 | if (!mysqld_user || !strcmp(mysqld_user, argument)) | ||
| 10742 | mysqld_user = argument; | ||
| 10743 | else | ||
| 10744 |
8/16✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 2 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 2 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 2 times.
✗ Branch 15 not taken.
|
2 | LogErr(WARNING_LEVEL, ER_THE_USER_ABIDES, argument, mysqld_user); |
| 10745 | break; | ||
| 10746 | case 's': | ||
| 10747 | 3 | if (argument && argument[0] == '0') { | |
| 10748 | ✗ | LogErr(WARNING_LEVEL, ER_DEPRECATE_MSG_NO_REPLACEMENT, | |
| 10749 | ✗ | "Disabling symbolic links using --skip-symbolic-links" | |
| 10750 | " (or equivalent) is the default. Consider not using" | ||
| 10751 | 233 | " this option as it"); | |
| 10752 |
1/2✓ Branch 0 taken 233 times.
✗ Branch 1 not taken.
|
233 | } else { |
| 10753 | 233 | LogErr(WARNING_LEVEL, ER_DEPRECATE_MSG_NO_REPLACEMENT, | |
| 10754 | 233 | "Enabling symbolic using --symbolic-links/-s (or equivalent)"); | |
| 10755 | 1 | } | |
| 10756 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | break; |
| 10757 | case 'L': | ||
| 10758 | 1 | push_deprecated_warn(nullptr, "--language/-l", "'--lc-messages-dir'"); | |
| 10759 | 3280 | [[fallthrough]]; | |
| 10760 | 3280 | case OPT_LC_MESSAGES_DIRECTORY: | |
| 10761 | 3280 | strmake(lc_messages_dir, argument, sizeof(lc_messages_dir) - 1); | |
| 10762 | 2 | lc_messages_dir_ptr = lc_messages_dir; | |
| 10763 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | break; |
| 10764 | case OPT_SHOW_SLAVE_AUTH_INFO_DEPRECATED: | ||
| 10765 | 2 | push_deprecated_warn(nullptr, "show-slave-auth-info", | |
| 10766 | 22 | "show-replica-auth-info"); | |
| 10767 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | break; |
| 10768 | case OPT_BINLOG_FORMAT: | ||
| 10769 | 22 | binlog_format_used = true; | |
| 10770 | 22 | break; | |
| 10771 | 22 | case OPT_BINLOG_MAX_FLUSH_QUEUE_TIME: | |
| 10772 | 22 | push_deprecated_warn_no_replacement(nullptr, | |
| 10773 | 22 | "--binlog_max_flush_queue_time"); | |
| 10774 | 35019 | break; | |
| 10775 | case OPT_EXPIRE_LOGS_DAYS: | ||
| 10776 | push_deprecated_warn(nullptr, "expire-logs-days", | ||
| 10777 | "binlog_expire_logs_seconds"); | ||
| 10778 | expire_logs_days_supplied = true; | ||
| 10779 | break; | ||
| 10780 | case OPT_BINLOG_EXPIRE_LOGS_SECONDS: | ||
| 10781 | binlog_expire_logs_seconds_supplied = true; | ||
| 10782 | break; | ||
| 10783 | case OPT_SSL_KEY: | ||
| 10784 | case OPT_SSL_CERT: | ||
| 10785 | case OPT_SSL_CA: | ||
| 10786 | 35019 | case OPT_SSL_CAPATH: | |
| 10787 | 35019 | case OPT_SSL_CIPHER: | |
| 10788 | 29 | case OPT_TLS_CIPHERSUITES: | |
| 10789 | 29 | case OPT_SSL_CRL: | |
| 10790 |
2/4✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 29 times.
|
29 | case OPT_SSL_CRLPATH: |
| 10791 | ✗ | /* | |
| 10792 | ✗ | Enable use of SSL if we are using any ssl option. | |
| 10793 | One can disable SSL later by using --skip-ssl or --ssl=0. | ||
| 10794 | 29 | */ | |
| 10795 | 4 | opt_use_ssl = true; | |
| 10796 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 3 times.
|
4 | break; |
| 10797 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case OPT_TLS_VERSION: |
| 10798 | opt_use_ssl = true; | ||
| 10799 |
1/2✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
|
3 | if (validate_tls_version(argument)) { |
| 10800 | LogErr(ERROR_LEVEL, ER_INVALID_TLS_VERSION, argument); | ||
| 10801 | 4 | return true; | |
| 10802 | 146 | } | |
| 10803 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 140 times.
|
146 | break; |
| 10804 |
1/2✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
|
6 | case OPT_USE_ADMIN_SSL: |
| 10805 | if (opt_use_admin_ssl) | ||
| 10806 |
1/2✓ Branch 0 taken 140 times.
✗ Branch 1 not taken.
|
140 | push_deprecated_warn_no_replacement(nullptr, "--admin-ssl=on"); |
| 10807 | 146 | else | |
| 10808 | ✗ | push_deprecated_warn(nullptr, "--admin-ssl=off", | |
| 10809 | "--admin-tls-version=invalid"); | ||
| 10810 | break; | ||
| 10811 | case OPT_USE_SSL: | ||
| 10812 | if (opt_use_ssl) | ||
| 10813 | push_deprecated_warn_no_replacement(nullptr, "--ssl=on"); | ||
| 10814 | else | ||
| 10815 | push_deprecated_warn(nullptr, "--ssl=off", "--tls-version=invalid"); | ||
| 10816 | break; | ||
| 10817 | case OPT_ADMIN_SSL_KEY: | ||
| 10818 | case OPT_ADMIN_SSL_CERT: | ||
| 10819 | case OPT_ADMIN_SSL_CA: | ||
| 10820 | ✗ | case OPT_ADMIN_SSL_CAPATH: | |
| 10821 | ✗ | case OPT_ADMIN_SSL_CIPHER: | |
| 10822 | ✗ | case OPT_ADMIN_TLS_CIPHERSUITES: | |
| 10823 | ✗ | case OPT_ADMIN_SSL_CRL: | |
| 10824 | ✗ | case OPT_ADMIN_SSL_CRLPATH: | |
| 10825 | ✗ | /* | |
| 10826 | ✗ | Enable use of SSL if we are using any ssl option. | |
| 10827 | ✗ | One can disable SSL later by using --skip-admin-ssl or --admin-ssl=0. | |
| 10828 | ✗ | */ | |
| 10829 | g_admin_ssl_configured = true; | ||
| 10830 | ✗ | opt_use_admin_ssl = true; | |
| 10831 | ✗ | break; | |
| 10832 | ✗ | case OPT_ADMIN_TLS_VERSION: | |
| 10833 | ✗ | g_admin_ssl_configured = true; | |
| 10834 | 1 | opt_use_admin_ssl = true; | |
| 10835 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | if (validate_tls_version(argument)) { |
| 10836 | 1 | LogErr(ERROR_LEVEL, ER_INVALID_TLS_VERSION, argument); | |
| 10837 | 1 | return true; | |
| 10838 | ✗ | } | |
| 10839 | ✗ | break; | |
| 10840 | ✗ | case 'V': | |
| 10841 | 4772 | print_server_version(); | |
| 10842 | 4772 | exit(MYSQLD_SUCCESS_EXIT); | |
| 10843 |
2/2✓ Branch 0 taken 333 times.
✓ Branch 1 taken 4439 times.
|
4772 | case 'T': |
| 10844 | test_flags = argument ? (uint)atoi(argument) : 0; | ||
| 10845 |
1/2✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
|
333 | opt_endinfo = true; |
| 10846 |
1/2✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
|
333 | break; |
| 10847 | 333 | case (int)OPT_ISAM_LOG: | |
| 10848 | opt_myisam_log = true; | ||
| 10849 | break; | ||
| 10850 | 4772 | case (int)OPT_BIN_LOG: | |
| 10851 | 4772 | opt_bin_log = (argument != disabled_my_option); | |
| 10852 | 12 | if (!opt_bin_log) { | |
| 10853 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | // Clear the binlog basename used by any previous --log-bin |
| 10854 |
4/6✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
|
12 | if (opt_bin_logname) { |
| 10855 |
9/18✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 6 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 6 times.
✗ Branch 17 not taken.
|
6 | my_free(opt_bin_logname); |
| 10856 | opt_bin_logname = nullptr; | ||
| 10857 | 6 | } | |
| 10858 | } | ||
| 10859 | 6 | log_bin_supplied = true; | |
| 10860 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
|
12 | break; |
| 10861 | 34 | case (int)OPT_REPLICA_ENABLE_EVENT: { | |
| 10862 |
3/4✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22 times.
✓ Branch 3 taken 12 times.
|
34 | std::ostringstream message{}; |
| 10863 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | if (Rpl_event_ctx::get_instance().process_argument(argument, message)) { |
| 10864 |
1/2✓ Branch 0 taken 22 times.
✗ Branch 1 not taken.
|
22 | LogErr(ERROR_LEVEL, ER_RPL_ENABLE_EVENT_ADD_WILD_PATTERN_FAILED, |
| 10865 | argument, message.str().c_str()); | ||
| 10866 | return true; | ||
| 10867 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | } |
| 10868 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | break; |
| 10869 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | } |
| 10870 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | case (int)OPT_REPLICATE_IGNORE_DB: { |
| 10871 | if (is_rpl_global_filter_setting(argument)) { | ||
| 10872 | rpl_global_filter.add_ignore_db(argument); | ||
| 10873 | 34 | rpl_global_filter.ignore_db_statistics.set_all( | |
| 10874 | CONFIGURED_BY_STARTUP_OPTIONS); | ||
| 10875 | 63 | } else { | |
| 10876 |
3/4✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 20 times.
|
63 | parse_filter_arg(&channel_name, &filter_val, argument); |
| 10877 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); |
| 10878 |
1/2✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
|
43 | rpl_filter->add_ignore_db(filter_val); |
| 10879 | rpl_filter->ignore_db_statistics.set_all( | ||
| 10880 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | ||
| 10881 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | } |
| 10882 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | break; |
| 10883 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | } |
| 10884 |
1/2✓ Branch 0 taken 20 times.
✗ Branch 1 not taken.
|
20 | case (int)OPT_REPLICATE_DO_DB: { |
| 10885 | if (is_rpl_global_filter_setting(argument)) { | ||
| 10886 | rpl_global_filter.add_do_db(argument); | ||
| 10887 | 63 | rpl_global_filter.do_db_statistics.set_all( | |
| 10888 | CONFIGURED_BY_STARTUP_OPTIONS); | ||
| 10889 | 54 | } else { | |
| 10890 | parse_filter_arg(&channel_name, &filter_val, argument); | ||
| 10891 |
3/4✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40 times.
✓ Branch 3 taken 14 times.
|
54 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); |
| 10892 |
3/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 28 times.
|
43 | rpl_filter->add_do_db(filter_val); |
| 10893 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | rpl_filter->do_db_statistics.set_all( |
| 10894 |
1/2✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
|
28 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); |
| 10895 | } | ||
| 10896 | break; | ||
| 10897 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | } |
| 10898 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | case (int)OPT_REPLICATE_REWRITE_DB: { |
| 10899 |
3/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 11 times.
|
14 | char *key, *val; |
| 10900 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (is_rpl_global_filter_setting(argument)) { |
| 10901 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | if (parse_replicate_rewrite_db(&key, &val, argument)) return true; |
| 10902 | rpl_global_filter.add_db_rewrite(key, val); | ||
| 10903 | rpl_global_filter.rewrite_db_statistics.set_all( | ||
| 10904 | 39 | CONFIGURED_BY_STARTUP_OPTIONS); | |
| 10905 | } else { | ||
| 10906 | parse_filter_arg(&channel_name, &filter_val, argument); | ||
| 10907 | 18 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); | |
| 10908 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | if (parse_replicate_rewrite_db(&key, &val, filter_val)) return true; |
| 10909 | 18 | rpl_filter->add_db_rewrite(key, val); | |
| 10910 | rpl_filter->rewrite_db_statistics.set_all( | ||
| 10911 | 8 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | |
| 10912 |
1/2✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
|
8 | } |
| 10913 | 8 | break; | |
| 10914 | } | ||
| 10915 | 59 | ||
| 10916 |
3/4✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 47 times.
✓ Branch 3 taken 12 times.
|
59 | case (int)OPT_BINLOG_IGNORE_DB: { |
| 10917 |
3/4✓ Branch 0 taken 47 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 46 times.
|
47 | binlog_filter->add_ignore_db(argument); |
| 10918 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | break; |
| 10919 | 1 | } | |
| 10920 | case (int)OPT_BINLOG_DO_DB: { | ||
| 10921 |
1/2✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
|
46 | binlog_filter->add_do_db(argument); |
| 10922 | break; | ||
| 10923 | } | ||
| 10924 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | case (int)OPT_REPLICATE_DO_TABLE: { |
| 10925 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (is_rpl_global_filter_setting(argument)) { |
| 10926 |
3/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
|
12 | if (rpl_global_filter.add_do_table_array(argument)) { |
| 10927 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(ERROR_LEVEL, ER_RPL_CANT_ADD_DO_TABLE, argument); |
| 10928 | 1 | return true; | |
| 10929 | } | ||
| 10930 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | rpl_global_filter.do_table_statistics.set_all( |
| 10931 | CONFIGURED_BY_STARTUP_OPTIONS); | ||
| 10932 | } else { | ||
| 10933 | 57 | parse_filter_arg(&channel_name, &filter_val, argument); | |
| 10934 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); | ||
| 10935 | 27 | if (rpl_filter->add_do_table_array(filter_val)) { | |
| 10936 |
3/4✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15 times.
✓ Branch 3 taken 12 times.
|
27 | LogErr(ERROR_LEVEL, ER_RPL_CANT_ADD_DO_TABLE, argument); |
| 10937 |
3/4✓ Branch 0 taken 15 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 14 times.
|
15 | return true; |
| 10938 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | } |
| 10939 | 1 | rpl_filter->do_table_statistics.set_all( | |
| 10940 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | ||
| 10941 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | } |
| 10942 | break; | ||
| 10943 | } | ||
| 10944 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | case (int)OPT_REPLICATE_WILD_DO_TABLE: { |
| 10945 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (is_rpl_global_filter_setting(argument)) { |
| 10946 |
3/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
|
12 | if (rpl_global_filter.add_wild_do_table(argument)) { |
| 10947 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(ERROR_LEVEL, ER_RPL_FILTER_ADD_WILD_DO_TABLE_FAILED, argument); |
| 10948 | 1 | return true; | |
| 10949 | } | ||
| 10950 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | rpl_global_filter.wild_do_table_statistics.set_all( |
| 10951 | CONFIGURED_BY_STARTUP_OPTIONS); | ||
| 10952 | } else { | ||
| 10953 | 25 | parse_filter_arg(&channel_name, &filter_val, argument); | |
| 10954 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); | ||
| 10955 | 40 | if (rpl_filter->add_wild_do_table(filter_val)) { | |
| 10956 |
3/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 12 times.
|
40 | LogErr(ERROR_LEVEL, ER_RPL_FILTER_ADD_WILD_DO_TABLE_FAILED, argument); |
| 10957 |
3/4✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 27 times.
|
28 | return true; |
| 10958 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | } |
| 10959 | rpl_filter->wild_do_table_statistics.set_all( | ||
| 10960 | 1 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | |
| 10961 | } | ||
| 10962 |
1/2✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
|
27 | break; |
| 10963 | } | ||
| 10964 | case (int)OPT_REPLICATE_WILD_IGNORE_TABLE: { | ||
| 10965 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (is_rpl_global_filter_setting(argument)) { |
| 10966 |
1/2✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
|
12 | if (rpl_global_filter.add_wild_ignore_table(argument)) { |
| 10967 |
3/4✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11 times.
|
12 | LogErr(ERROR_LEVEL, ER_RPL_FILTER_ADD_WILD_IGNORE_TABLE_FAILED, |
| 10968 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | argument); |
| 10969 | return true; | ||
| 10970 | 1 | } | |
| 10971 | rpl_global_filter.wild_ignore_table_statistics.set_all( | ||
| 10972 |
1/2✓ Branch 0 taken 11 times.
✗ Branch 1 not taken.
|
11 | CONFIGURED_BY_STARTUP_OPTIONS); |
| 10973 | } else { | ||
| 10974 | parse_filter_arg(&channel_name, &filter_val, argument); | ||
| 10975 | 38 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); | |
| 10976 | if (rpl_filter->add_wild_ignore_table(filter_val)) { | ||
| 10977 | 86 | LogErr(ERROR_LEVEL, ER_RPL_FILTER_ADD_WILD_IGNORE_TABLE_FAILED, | |
| 10978 |
3/4✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
✓ Branch 3 taken 14 times.
|
86 | argument); |
| 10979 |
3/4✓ Branch 0 taken 72 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 71 times.
|
72 | return true; |
| 10980 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | } |
| 10981 | 1 | rpl_filter->wild_ignore_table_statistics.set_all( | |
| 10982 | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | ||
| 10983 |
1/2✓ Branch 0 taken 71 times.
✗ Branch 1 not taken.
|
71 | } |
| 10984 | break; | ||
| 10985 | } | ||
| 10986 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | case (int)OPT_REPLICATE_IGNORE_TABLE: { |
| 10987 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | if (is_rpl_global_filter_setting(argument)) { |
| 10988 |
3/4✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 13 times.
|
14 | if (rpl_global_filter.add_ignore_table_array(argument)) { |
| 10989 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | LogErr(ERROR_LEVEL, ER_RPL_CANT_ADD_IGNORE_TABLE, argument); |
| 10990 | 1 | return true; | |
| 10991 | } | ||
| 10992 |
1/2✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
|
13 | rpl_global_filter.ignore_table_statistics.set_all( |
| 10993 | CONFIGURED_BY_STARTUP_OPTIONS); | ||
| 10994 | } else { | ||
| 10995 | 84 | parse_filter_arg(&channel_name, &filter_val, argument); | |
| 10996 | rpl_filter = rpl_channel_filters.get_channel_filter(channel_name); | ||
| 10997 | 3254 | if (rpl_filter->add_ignore_table_array(filter_val)) { | |
| 10998 |
1/2✓ Branch 0 taken 3254 times.
✗ Branch 1 not taken.
|
3254 | LogErr(ERROR_LEVEL, ER_RPL_CANT_ADD_IGNORE_TABLE, argument); |
| 10999 | return true; | ||
| 11000 | } | ||
| 11001 | 3254 | rpl_filter->ignore_table_statistics.set_all( | |
| 11002 | ✗ | CONFIGURED_BY_STARTUP_OPTIONS_FOR_CHANNEL); | |
| 11003 | ✗ | } | |
| 11004 | ✗ | break; | |
| 11005 | ✗ | } | |
| 11006 | ✗ | case (int)OPT_MASTER_RETRY_COUNT: | |
| 11007 | ✗ | push_deprecated_warn(nullptr, "--master-retry-count", | |
| 11008 | ✗ | "'CHANGE REPLICATION SOURCE TO " | |
| 11009 | ✗ | "SOURCE_RETRY_COUNT = <num>'"); | |
| 11010 | ✗ | break; | |
| 11011 | 1 | case (int)OPT_SKIP_NEW: | |
| 11012 | 1 | opt_specialflag |= SPECIAL_NO_NEW_FUNC; | |
| 11013 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | delay_key_write_options = DELAY_KEY_WRITE_NONE; |
| 11014 | myisam_concurrent_insert = 0; | ||
| 11015 | 1 | myisam_recover_options = HA_RECOVER_OFF; | |
| 11016 | 41 | sp_automatic_privileges = false; | |
| 11017 |
5/6✓ Branch 0 taken 3 times.
✓ Branch 1 taken 38 times.
✓ Branch 2 taken 3 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 39 times.
|
44 | my_enable_symlinks = false; |
| 11018 |
3/4✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 1 times.
|
3 | ha_open_options &= ~(HA_OPEN_ABORT_IF_CRASHED | HA_OPEN_DELAY_KEY_WRITE); |
| 11019 | 2 | break; | |
| 11020 | case (int)OPT_SKIP_HOST_CACHE_DEPRECATED: | ||
| 11021 | 39 | opt_specialflag |= SPECIAL_NO_HOST_CACHE; | |
| 11022 | 39 | push_deprecated_warn(nullptr, "--skip-host-cache", | |
| 11023 | "SET GLOBAL host_cache_size=0"); | ||
| 11024 | 41 | break; | |
| 11025 | 11596 | case (int)OPT_SKIP_RESOLVE: | |
| 11026 | 11596 | if (argument && (argument == disabled_my_option || | |
| 11027 | 11596 | !my_strcasecmp(system_charset_info, argument, "OFF"))) | |
| 11028 | 11596 | opt_skip_name_resolve = false; | |
| 11029 | 5 | else { | |
| 11030 | 5 | opt_skip_name_resolve = true; | |
| 11031 | 5 | opt_specialflag |= SPECIAL_NO_RESOLVE; | |
| 11032 | 5 | } | |
| 11033 | 18 | break; | |
| 11034 | 18 | case (int)OPT_WANT_CORE: | |
| 11035 | 18 | test_flags |= TEST_CORE_ON_SIGNAL; | |
| 11036 | 11752 | opt_corefile = (argument != disabled_my_option); | |
| 11037 | break; | ||
| 11038 | case (int)OPT_COREDUMPER: | ||
| 11039 | test_flags |= TEST_CORE_ON_SIGNAL; | ||
| 11040 | opt_libcoredumper = (argument != disabled_my_option); | ||
| 11041 | break; | ||
| 11042 | 11752 | case (int)OPT_SKIP_STACK_TRACE: | |
| 11043 | 11752 | test_flags |= TEST_NO_STACKTRACE; | |
| 11044 | 337 | break; | |
| 11045 | 337 | case OPT_SERVER_ID: | |
| 11046 | 337 | /* | |
| 11047 | Consider that one received a Server Id when 2 conditions are present: | ||
| 11048 | 11436 | 1) The argument is on the list | |
| 11049 | 2) There is a value present | ||
| 11050 | */ | ||
| 11051 | server_id_supplied = (*argument != 0); | ||
| 11052 | break; | ||
| 11053 | case OPT_LOWER_CASE_TABLE_NAMES: | ||
| 11054 | lower_case_table_names_used = true; | ||
| 11055 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11436 times.
|
11436 | break; |
| 11056 | #if defined(ENABLED_DEBUG_SYNC) | ||
| 11057 | ✗ | case OPT_DEBUG_SYNC_TIMEOUT: | |
| 11058 | /* | ||
| 11059 | Debug Sync Facility. See debug_sync.cc. | ||
| 11060 | 11436 | Default timeout for WAIT_FOR action. | |
| 11061 | Default value is zero (facility disabled). | ||
| 11062 | 865 | If option is given without an argument, supply a non-zero value. | |
| 11063 | */ | ||
| 11064 | if (!argument) { | ||
| 11065 | /* purecov: begin tested */ | ||
| 11066 | opt_debug_sync_timeout = DEBUG_SYNC_DEFAULT_WAIT_TIMEOUT; | ||
| 11067 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 863 times.
|
865 | /* purecov: end */ |
| 11068 | 2 | } | |
| 11069 | 865 | break; | |
| 11070 | #endif /* defined(ENABLED_DEBUG_SYNC) */ | ||
| 11071 | 1501 | case OPT_LOG_ERROR: | |
| 11072 |
1/2✓ Branch 0 taken 1501 times.
✗ Branch 1 not taken.
|
1501 | /* |
| 11073 |
2/4✓ Branch 0 taken 1501 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1501 times.
✗ Branch 3 not taken.
|
1501 | "No --log-error" == "write errors to stderr", |
| 11074 | 1501 | "--log-error without argument" == "write errors to a file". | |
| 11075 | 2271 | */ | |
| 11076 |
1/2✓ Branch 0 taken 2271 times.
✗ Branch 1 not taken.
|
2271 | if (argument == nullptr) /* no argument */ |
| 11077 | log_error_dest = ""; | ||
| 11078 | 3197 | break; | |
| 11079 |
2/4✓ Branch 0 taken 3197 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3197 times.
✗ Branch 3 not taken.
|
3197 | |
| 11080 | 3197 | case OPT_EARLY_PLUGIN_LOAD: | |
| 11081 | 11675 | free_list(opt_early_plugin_load_list_ptr); | |
| 11082 | opt_early_plugin_load_list_ptr->push_back(new i_string(argument)); | ||
| 11083 | break; | ||
| 11084 | case OPT_PLUGIN_LOAD: | ||
| 11085 | free_list(opt_plugin_load_list_ptr); | ||
| 11086 | [[fallthrough]]; | ||
| 11087 | case OPT_PLUGIN_LOAD_ADD: | ||
| 11088 | opt_plugin_load_list_ptr->push_back(new i_string(argument)); | ||
| 11089 | break; | ||
| 11090 | case OPT_PFS_INSTRUMENT: { | ||
| 11091 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE | ||
| 11092 | /* | ||
| 11093 | Parse instrument name and value from argument string. Handle leading | ||
| 11094 | 11675 | and trailing spaces. Also handle single quotes. | |
| 11095 | 11675 | ||
| 11096 | 11675 | Acceptable: | |
| 11097 | 11675 | performance_schema_instrument = ' foo/%/bar/ = ON ' | |
| 11098 | performance_schema_instrument = '%=OFF' | ||
| 11099 | 11675 | Not acceptable: | |
| 11100 | performance_schema_instrument = '' foo/%/bar = ON '' | ||
| 11101 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11675 times.
|
11675 | performance_schema_instrument = '%='OFF'' |
| 11102 | */ | ||
| 11103 | char *name = argument, *p = nullptr, *val = nullptr; | ||
| 11104 | 11675 | bool quote = false; /* true if quote detected */ | |
| 11105 | bool error = true; /* false if no errors detected */ | ||
| 11106 | const int PFS_BUFFER_SIZE = 128; | ||
| 11107 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 11671 times.
|
11675 | char orig_argument[PFS_BUFFER_SIZE + 1]; |
| 11108 | orig_argument[0] = 0; | ||
| 11109 | |||
| 11110 | 11671 | if (!argument) goto pfs_error; | |
| 11111 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11671 times.
|
11671 | |
| 11112 | /* Save original argument string for error reporting */ | ||
| 11113 | strncpy(orig_argument, argument, PFS_BUFFER_SIZE); | ||
| 11114 |
5/6✓ Branch 0 taken 11683 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 11675 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 11671 times.
|
11683 | |
| 11115 | /* Split instrument name and value at the equal sign */ | ||
| 11116 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 8 times.
|
12 | if (!(p = strchr(argument, '='))) goto pfs_error; |
| 11117 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | |
| 11118 | 4 | /* Get option value */ | |
| 11119 | val = p + 1; | ||
| 11120 | ✗ | if (!*val) goto pfs_error; | |
| 11121 | |||
| 11122 | 12 | /* Trim leading spaces and quote from the instrument name */ | |
| 11123 | while (*name && (my_isspace(mysqld_charset, *name) || (*name == '\''))) { | ||
| 11124 | /* One quote allowed */ | ||
| 11125 | if (*name == '\'') { | ||
| 11126 |
3/4✓ Branch 0 taken 11692 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 11671 times.
|
11692 | if (!quote) |
| 11127 | 11671 | quote = true; | |
| 11128 | else | ||
| 11129 | goto pfs_error; | ||
| 11130 |
3/4✓ Branch 0 taken 11671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11670 times.
|
11671 | } |
| 11131 | name++; | ||
| 11132 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11671 times.
|
11671 | } |
| 11133 | |||
| 11134 | /* Trim trailing spaces from instrument name */ | ||
| 11135 |
3/4✓ Branch 0 taken 11687 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 11671 times.
|
11687 | while ((p > name) && my_isspace(mysqld_charset, p[-1])) p--; |
| 11136 | *p = 0; | ||
| 11137 | |||
| 11138 | 11671 | /* Remove trailing slash from instrument name */ | |
| 11139 |
5/6✓ Branch 0 taken 11680 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 11675 times.
✓ Branch 4 taken 5 times.
✓ Branch 5 taken 11670 times.
|
11680 | if (p > name && (p[-1] == '/')) p[-1] = 0; |
| 11140 | |||
| 11141 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 5 times.
|
10 | if (!*name) goto pfs_error; |
| 11142 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1 times.
|
5 | |
| 11143 | 4 | /* Trim leading spaces from option value */ | |
| 11144 | while (*val && my_isspace(mysqld_charset, *val)) val++; | ||
| 11145 | 1 | ||
| 11146 | /* Trim trailing spaces and matching quote from value */ | ||
| 11147 | 9 | p = val + strlen(val); | |
| 11148 | while (p > val && (my_isspace(mysqld_charset, p[-1]) || p[-1] == '\'')) { | ||
| 11149 | /* One matching quote allowed */ | ||
| 11150 | 11670 | if (p[-1] == '\'') { | |
| 11151 | if (quote) | ||
| 11152 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11670 times.
|
11670 | quote = false; |
| 11153 | else | ||
| 11154 | goto pfs_error; | ||
| 11155 |
3/4✓ Branch 0 taken 11670 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 11668 times.
|
11670 | } |
| 11156 | p--; | ||
| 11157 | 11668 | } | |
| 11158 | |||
| 11159 | 11675 | *p = 0; | |
| 11160 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 11668 times.
|
11675 | |
| 11161 |
8/16✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | if (!*val) goto pfs_error; |
| 11162 | 7 | ||
| 11163 | /* Add instrument name and value to array of configuration options */ | ||
| 11164 | if (add_pfs_instr_to_array(name, val)) goto pfs_error; | ||
| 11165 | 11668 | ||
| 11166 | error = false; | ||
| 11167 | 2 | ||
| 11168 | 2 | pfs_error: | |
| 11169 | 2 | if (error) { | |
| 11170 | 2 | LogErr(WARNING_LEVEL, ER_INVALID_INSTRUMENT, orig_argument); | |
| 11171 | 2 | return false; | |
| 11172 | 2 | } | |
| 11173 | 2 | #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */ | |
| 11174 | 2 | break; | |
| 11175 | 2 | } | |
| 11176 | 7 | case OPT_THREAD_CACHE_SIZE: | |
| 11177 |
8/16✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 7 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 7 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 7 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 7 times.
✗ Branch 15 not taken.
|
7 | thread_cache_size_specified = true; |
| 11178 | 7 | break; | |
| 11179 | ✗ | case OPT_HOST_CACHE_SIZE: | |
| 11180 | ✗ | host_cache_size_specified = true; | |
| 11181 | ✗ | break; | |
| 11182 | ✗ | case OPT_TABLE_DEFINITION_CACHE: | |
| 11183 | ✗ | table_definition_cache_specified = true; | |
| 11184 | ✗ | break; | |
| 11185 | ✗ | case OPT_SKIP_INNODB: | |
| 11186 | ✗ | LogErr(WARNING_LEVEL, ER_INNODB_MANDATORY); | |
| 11187 | ✗ | break; | |
| 11188 | ✗ | case OPT_AVOID_TEMPORAL_UPGRADE: | |
| 11189 | ✗ | push_deprecated_warn_no_replacement(nullptr, "avoid_temporal_upgrade"); | |
| 11190 | ✗ | break; | |
| 11191 | ✗ | case OPT_SHOW_OLD_TEMPORALS: | |
| 11192 | ✗ | push_deprecated_warn_no_replacement(nullptr, "show_old_temporals"); | |
| 11193 | break; | ||
| 11194 | ✗ | case 'p': | |
| 11195 | ✗ | if (argument) { | |
| 11196 | ✗ | char *start = argument; | |
| 11197 | ✗ | my_free(opt_keyring_migration_password); | |
| 11198 | opt_keyring_migration_password = | ||
| 11199 | my_strdup(PSI_NOT_INSTRUMENTED, argument, MYF(MY_FAE)); | ||
| 11200 | while (*argument) *argument++ = 'x'; | ||
| 11201 | ✗ | if (*start) start[1] = 0; | |
| 11202 | ✗ | } else | |
| 11203 | 370 | opt_keyring_migration_password = get_tty_password(NullS); | |
| 11204 | 370 | migrate_connect_options = true; | |
| 11205 | 370 | break; | |
| 11206 | 137 | case OPT_KEYRING_MIGRATION_USER: | |
| 11207 | 137 | case OPT_KEYRING_MIGRATION_HOST: | |
| 11208 | 137 | case OPT_KEYRING_MIGRATION_SOCKET: | |
| 11209 | 2782 | case OPT_KEYRING_MIGRATION_PORT: | |
| 11210 | migrate_connect_options = true; | ||
| 11211 |
1/2✓ Branch 0 taken 2782 times.
✗ Branch 1 not taken.
|
2782 | break; |
| 11212 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 2778 times.
|
2782 | case OPT_LOG_REPLICA_UPDATES: |
| 11213 |
8/16✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 4 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 4 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 4 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 4 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 4 times.
✗ Branch 15 not taken.
|
4 | log_replica_updates_supplied = true; |
| 11214 | break; | ||
| 11215 | 2782 | case OPT_REPLICA_PRESERVE_COMMIT_ORDER: | |
| 11216 | ✗ | replica_preserve_commit_order_supplied = true; | |
| 11217 | break; | ||
| 11218 | case OPT_ENFORCE_GTID_CONSISTENCY: { | ||
| 11219 | const char *wrong_value = | ||
| 11220 | fixup_enforce_gtid_consistency_command_line(argument); | ||
| 11221 | if (wrong_value != nullptr) | ||
| 11222 | LogErr(WARNING_LEVEL, ER_INVALID_VALUE_FOR_ENFORCE_GTID_CONSISTENCY, | ||
| 11223 | ✗ | wrong_value); | |
| 11224 | 4 | } break; | |
| 11225 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
4 | case OPT_NAMED_PIPE_FULL_ACCESS_GROUP: |
| 11226 | 4 | #ifdef _WIN32 | |
| 11227 | 5 | if (!is_valid_named_pipe_full_access_group(argument)) { | |
| 11228 |
1/2✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
|
5 | LogErr(ERROR_LEVEL, ER_INVALID_NAMED_PIPE_FULL_ACCESS_GROUP); |
| 11229 | 5 | return 1; | |
| 11230 | 2 | } | |
| 11231 |
1/2✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 | #endif // _WIN32 |
| 11232 | break; | ||
| 11233 | 2 | case OPT_RELAY_LOG_INFO_FILE: | |
| 11234 | 1 | push_deprecated_warn_no_replacement(nullptr, "--relay-log-info-file"); | |
| 11235 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | break; |
| 11236 | case OPT_MASTER_INFO_FILE: | ||
| 11237 | 1 | push_deprecated_warn_no_replacement(nullptr, "--master-info-file"); | |
| 11238 | 57 | break; | |
| 11239 |
1/2✓ Branch 0 taken 57 times.
✗ Branch 1 not taken.
|
57 | case OPT_LOG_BIN_USE_V1_ROW_EVENTS: |
| 11240 | 57 | push_deprecated_warn_no_replacement(nullptr, | |
| 11241 | 260 | "--log-bin-use-v1-row-events"); | |
| 11242 |
1/2✓ Branch 0 taken 260 times.
✗ Branch 1 not taken.
|
260 | break; |
| 11243 | case OPT_SLAVE_ROWS_SEARCH_ALGORITHMS: | ||
| 11244 | 260 | push_deprecated_warn_no_replacement(nullptr, | |
| 11245 | 100 | "--slave-rows-search-algorithms"); | |
| 11246 |
1/2✓ Branch 0 taken 100 times.
✗ Branch 1 not taken.
|
100 | break; |
| 11247 | case OPT_MASTER_INFO_REPOSITORY: | ||
| 11248 | 100 | push_deprecated_warn_no_replacement(nullptr, "--master-info-repository"); | |
| 11249 | 1 | break; | |
| 11250 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case OPT_RELAY_LOG_INFO_REPOSITORY: |
| 11251 | push_deprecated_warn_no_replacement(nullptr, | ||
| 11252 | 1 | "--relay-log-info-repository"); | |
| 11253 | 1 | break; | |
| 11254 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | case OPT_TRANSACTION_WRITE_SET_EXTRACTION: |
| 11255 | 1 | push_deprecated_warn_no_replacement(nullptr, | |
| 11256 | 103 | "--transaction-write-set-extraction"); | |
| 11257 |
1/2✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
|
103 | break; |
| 11258 | 103 | case OPT_DISCONNECT_SLAVE_EVENT_COUNT: | |
| 11259 | 188 | push_deprecated_warn_no_replacement(nullptr, | |
| 11260 |
2/2✓ Branch 0 taken 14 times.
✓ Branch 1 taken 174 times.
|
188 | "--disconnect-slave-event-count"); |
| 11261 |
1/2✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
|
14 | break; |
| 11262 | case OPT_ABORT_SLAVE_EVENT_COUNT: | ||
| 11263 | push_deprecated_warn_no_replacement(nullptr, "--abort-slave-event-count"); | ||
| 11264 | 188 | break; | |
| 11265 | 1 | case OPT_REPLICA_PARALLEL_TYPE: | |
| 11266 |
1/2✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
|
1 | push_deprecated_warn_no_replacement(nullptr, "--replica-parallel-type"); |
| 11267 | break; | ||
| 11268 | 704203 | case OPT_REPLICA_PARALLEL_WORKERS: | |
| 11269 | if (opt_mts_replica_parallel_workers == 0) { | ||
| 11270 | push_deprecated_warn(nullptr, "--replica-parallel-workers=0", | ||
| 11271 | "'--replica-parallel-workers=1'"); | ||
| 11272 | } | ||
| 11273 | 48628 | break; | |
| 11274 | case OPT_OLD_STYLE_USER_LIMITS: | ||
| 11275 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 48624 times.
|
48628 | push_deprecated_warn_no_replacement(nullptr, "--old-style-user-limits"); |
| 11276 |
1/2✓ Branch 0 taken 48628 times.
✗ Branch 1 not taken.
|
48628 | } |
| 11277 | 48628 | return false; | |
| 11278 | } | ||
| 11279 | |||
| 11280 | /** Handle arguments for multiple key caches. */ | ||
| 11281 | |||
| 11282 | 97256 | static void *mysql_getopt_value(const char *keyname, size_t key_length, | |
| 11283 |
3/6✓ Branch 0 taken 48628 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48628 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 48628 times.
|
48628 | const struct my_option *option, int *error) { |
| 11284 | ✗ | if (error) *error = 0; | |
| 11285 | ✗ | switch (option->id) { | |
| 11286 | case OPT_KEY_BUFFER_SIZE: | ||
| 11287 |
4/5✓ Branch 0 taken 12160 times.
✓ Branch 1 taken 12156 times.
✓ Branch 2 taken 12156 times.
✓ Branch 3 taken 12156 times.
✗ Branch 4 not taken.
|
48628 | case OPT_KEY_CACHE_BLOCK_SIZE: |
| 11288 | 12160 | case OPT_KEY_CACHE_DIVISION_LIMIT: | |
| 11289 | 12160 | case OPT_KEY_CACHE_AGE_THRESHOLD: { | |
| 11290 | 12156 | KEY_CACHE *key_cache; | |
| 11291 | 12156 | if (!(key_cache = | |
| 11292 | 12156 | get_or_create_key_cache(std::string{keyname, key_length}))) { | |
| 11293 | 12156 | if (error) *error = EXIT_OUT_OF_MEMORY; | |
| 11294 | 12156 | return nullptr; | |
| 11295 | 12156 | } | |
| 11296 | switch (option->id) { | ||
| 11297 | case OPT_KEY_BUFFER_SIZE: | ||
| 11298 | return &key_cache->param_buff_size; | ||
| 11299 | ✗ | case OPT_KEY_CACHE_BLOCK_SIZE: | |
| 11300 | return &key_cache->param_block_size; | ||
| 11301 | case OPT_KEY_CACHE_DIVISION_LIMIT: | ||
| 11302 | return &key_cache->param_division_limit; | ||
| 11303 | case OPT_KEY_CACHE_AGE_THRESHOLD: | ||
| 11304 | return &key_cache->param_age_threshold; | ||
| 11305 | } | ||
| 11306 | } | ||
| 11307 | } | ||
| 11308 | return option->value; | ||
| 11309 | } | ||
| 11310 | |||
| 11311 | /** | ||
| 11312 | 12142 | Get server options from the command line, | |
| 11313 | and perform related server initializations. | ||
| 11314 | @param [in, out] argc_ptr command line options (count) | ||
| 11315 | 12142 | @param [in, out] argv_ptr command line options (values) | |
| 11316 | @return 0 on success | ||
| 11317 | |||
| 11318 | 12142 | @todo | |
| 11319 | 849940 | - FIXME add EXIT_TOO_MANY_ARGUMENTS to "mysys_err.h" and return that code? | |
| 11320 |
2/2✓ Branch 0 taken 837798 times.
✓ Branch 1 taken 12142 times.
|
849940 | */ |
| 11321 | 837798 | static int get_options(int *argc_ptr, char ***argv_ptr) { | |
| 11322 | int ho_error; | ||
| 11323 | 12142 | ||
| 11324 | 12142 | my_getopt_register_get_addr(mysql_getopt_value); | |
| 11325 | |||
| 11326 | /* prepare all_options array */ | ||
| 11327 | 12142 | all_options.reserve(array_elements(my_long_options)); | |
| 11328 | for (my_option *opt = my_long_options; | ||
| 11329 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 12111 times.
|
12142 | opt < my_long_options + array_elements(my_long_options) - 1; opt++) { |
| 11330 | all_options.push_back(*opt); | ||
| 11331 | 31 | } | |
| 11332 | sys_var_add_options(&all_options, sys_var::PARSE_NORMAL); | ||
| 11333 | add_terminator(&all_options); | ||
| 11334 | |||
| 11335 | /* Skip unknown options so that they may be processed later by plugins */ | ||
| 11336 | my_getopt_skip_unknown = true; | ||
| 11337 | 12111 | ||
| 11338 |
4/4✓ Branch 0 taken 12109 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 35 times.
✓ Branch 3 taken 12076 times.
|
24220 | if ((ho_error = handle_options(argc_ptr, argv_ptr, &all_options[0], |
| 11339 |
2/2✓ Branch 0 taken 33 times.
✓ Branch 1 taken 12076 times.
|
12109 | mysqld_get_one_option))) |
| 11340 | return ho_error; | ||
| 11341 | 35 | ||
| 11342 |
7/14✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 35 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 35 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 35 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 35 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 35 times.
✗ Branch 13 not taken.
|
35 | // update suppression list in filter engine |
| 11343 | { | ||
| 11344 | int rr; | ||
| 11345 | // try to set the list | ||
| 11346 | if (((rr = log_builtins_filter_parse_suppression_list( | ||
| 11347 | opt_log_error_suppression_list, false)) != 0) || | ||
| 11348 | ((rr = log_builtins_filter_parse_suppression_list( | ||
| 11349 | opt_log_error_suppression_list, true)) != 0)) { | ||
| 11350 | rr = -(rr + 1); | ||
| 11351 | LogErr(ERROR_LEVEL, ER_CANT_SET_ERROR_SUPPRESSION_LIST_FROM_COMMAND_LINE, | ||
| 11352 |
2/4✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 35 times.
✗ Branch 3 not taken.
|
35 | "log_error_suppression_list", &opt_log_error_suppression_list[rr]); |
| 11353 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | |
| 11354 | 35 | /* | |
| 11355 | We were given an illegal value at start-up, so the default will be | ||
| 11356 | used instead. We have reported the problem (and the dodgy value); | ||
| 11357 | let's now point our variable back at the default (i.e. the value | ||
| 11358 | actually used) so SELECT @@GLOBAL.log_error_suppression_list will | ||
| 11359 | render correct results. | ||
| 11360 | */ | ||
| 11361 | sys_var *var = find_static_system_variable("log_error_suppression_list"); | ||
| 11362 | 35 | if (var != nullptr) { | |
| 11363 |
1/2✓ Branch 0 taken 35 times.
✗ Branch 1 not taken.
|
35 | opt_log_error_suppression_list = (char *)var->get_default(); |
| 11364 | 35 | /* | |
| 11365 | During unit-testing, the log subsystem is not initialized, | ||
| 11366 | so while the default should always check out as a valid | ||
| 11367 | ✗ | argument, actually setting it will still fail in this | |
| 11368 | particular case as we cannot acquire the rule-set or its | ||
| 11369 | lock. | ||
| 11370 | */ | ||
| 11371 | if (log_builtins_filter_parse_suppression_list( | ||
| 11372 | opt_log_error_suppression_list, false) == 0) { | ||
| 11373 |
2/2✓ Branch 0 taken 12093 times.
✓ Branch 1 taken 18 times.
|
12111 | log_builtins_filter_parse_suppression_list( |
| 11374 | 12093 | opt_log_error_suppression_list, true); | |
| 11375 | } else { | ||
| 11376 | assert(false); /* purecov: inspected */ | ||
| 11377 | 12111 | } | |
| 11378 | 12111 | } | |
| 11379 | } | ||
| 11380 | } | ||
| 11381 | |||
| 11382 | if (!is_help_or_validate_option()) | ||
| 11383 | vector<my_option>().swap(all_options); // Deletes the vector contents. | ||
| 11384 | |||
| 11385 | /* Add back the program name handle_options removes */ | ||
| 11386 | (*argc_ptr)++; | ||
| 11387 |
11/18✓ Branch 0 taken 12098 times.
✓ Branch 1 taken 13 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12097 times.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1 times.
✗ Branch 17 not taken.
|
12111 | (*argv_ptr)--; |
| 11388 | |||
| 11389 |
4/4✓ Branch 0 taken 12101 times.
✓ Branch 1 taken 8 times.
✓ Branch 2 taken 12096 times.
✓ Branch 3 taken 5 times.
|
12109 | /* |
| 11390 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12096 times.
|
12096 | Options have been parsed. Now some of them need additional special |
| 11391 |
3/4✓ Branch 0 taken 12109 times.
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12111 times.
|
36318 | handling, like custom value checking, checking of incompatibilites |
| 11392 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
15 | between options, setting of multiple variables, etc. |
| 11393 | ✗ | Do them here. | |
| 11394 | */ | ||
| 11395 | 12111 | ||
| 11396 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | if (!opt_help && opt_verbose) LogErr(ERROR_LEVEL, ER_VERBOSE_REQUIRES_HELP); |
| 11397 | ✗ | ||
| 11398 | if ((opt_log_slow_admin_statements || opt_log_queries_not_using_indexes || | ||
| 11399 | opt_log_slow_replica_statements || | ||
| 11400 | global_system_variables.log_query_errors.check_variable_set()) && | ||
| 11401 | !opt_slow_log) | ||
| 11402 | LogErr(WARNING_LEVEL, ER_POINTLESS_WITHOUT_SLOWLOG); | ||
| 11403 | |||
| 11404 | if (global_system_variables.net_buffer_length > | ||
| 11405 | global_system_variables.max_allowed_packet) { | ||
| 11406 | LogErr(WARNING_LEVEL, ER_WASTEFUL_NET_BUFFER_SIZE, | ||
| 11407 |
4/4✓ Branch 0 taken 12093 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 12106 times.
|
24204 | global_system_variables.net_buffer_length, |
| 11408 |
2/2✓ Branch 0 taken 5 times.
✓ Branch 1 taken 12088 times.
|
12093 | global_system_variables.max_allowed_packet); |
| 11409 |
7/14✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 5 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
|
5 | } |
| 11410 | |||
| 11411 | 12111 | /* | |
| 11412 | 12111 | TIMESTAMP columns get implicit DEFAULT values when | |
| 11413 | 12111 | --explicit_defaults_for_timestamp is not set. | |
| 11414 | This behavior is deprecated now. | ||
| 11415 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | */ |
| 11416 | ✗ | if (!is_help_or_validate_option() && | |
| 11417 | !global_system_variables.explicit_defaults_for_timestamp) | ||
| 11418 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | LogErr(WARNING_LEVEL, ER_DEPRECATED_TIMESTAMP_IMPLICIT_DEFAULTS); |
| 11419 | |||
| 11420 | ✗ | opt_init_connect.length = strlen(opt_init_connect.str); | |
| 11421 | ✗ | opt_init_replica.length = strlen(opt_init_replica.str); | |
| 11422 | opt_mandatory_roles.length = strlen(opt_mandatory_roles.str); | ||
| 11423 | |||
| 11424 |
6/6✓ Branch 0 taken 317 times.
✓ Branch 1 taken 11794 times.
✓ Branch 2 taken 314 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 314 times.
✓ Branch 5 taken 11797 times.
|
12111 | if (global_system_variables.low_priority_updates) |
| 11425 | thr_upgraded_concurrent_insert_lock = TL_WRITE_LOW_PRIORITY; | ||
| 11426 |
2/2✓ Branch 0 taken 348 times.
✓ Branch 1 taken 11763 times.
|
12111 | |
| 11427 | if (ft_boolean_check_syntax_string( | ||
| 11428 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | pointer_cast<const uchar *>(ft_boolean_syntax))) { |
| 11429 | LogErr(ERROR_LEVEL, ER_FT_BOOL_SYNTAX_INVALID, ft_boolean_syntax); | ||
| 11430 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | return 1; |
| 11431 | } | ||
| 11432 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 12079 times.
|
12111 | |
| 11433 | if (opt_noacl && !is_help_or_validate_option()) opt_disable_networking = true; | ||
| 11434 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | |
| 11435 | 12111 | if (opt_disable_networking) mysqld_port = 0; | |
| 11436 | |||
| 11437 | ✗ | if (opt_skip_show_db) opt_specialflag |= SPECIAL_SKIP_SHOW_DB; | |
| 11438 | |||
| 11439 | if (myisam_flush) flush_time = 0; | ||
| 11440 | 12111 | ||
| 11441 |
2/2✓ Branch 0 taken 12108 times.
✓ Branch 1 taken 3 times.
|
12111 | if (opt_replica_skip_errors) add_replica_skip_errors(opt_replica_skip_errors); |
| 11442 | 12111 | ||
| 11443 | 12111 | if (global_system_variables.max_join_size == HA_POS_ERROR) | |
| 11444 | 12111 | global_system_variables.option_bits |= OPTION_BIG_SELECTS; | |
| 11445 | else | ||
| 11446 | global_system_variables.option_bits &= ~OPTION_BIG_SELECTS; | ||
| 11447 | |||
| 11448 | 12111 | // Synchronize @@global.autocommit value on --autocommit | |
| 11449 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | const ulonglong turn_bit_on = |
| 11450 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | opt_autocommit ? OPTION_AUTOCOMMIT : OPTION_NOT_AUTOCOMMIT; |
| 11451 | 12111 | global_system_variables.option_bits = | |
| 11452 | 12111 | (global_system_variables.option_bits & | |
| 11453 | ~(OPTION_NOT_AUTOCOMMIT | OPTION_AUTOCOMMIT)) | | ||
| 11454 | 12111 | turn_bit_on; | |
| 11455 | 12111 | ||
| 11456 | // Synchronize @@global.autocommit metadata on --autocommit | ||
| 11457 |
2/2✓ Branch 0 taken 12109 times.
✓ Branch 1 taken 2 times.
|
12111 | my_option *opt = &my_long_options[3]; |
| 11458 | assert(strcmp(opt->name, "autocommit") == 0); | ||
| 11459 | assert(opt->arg_source != nullptr); | ||
| 11460 | 12111 | Sys_autocommit_ptr->set_source_name(opt->arg_source->m_path_name); | |
| 11461 | Sys_autocommit_ptr->set_source(opt->arg_source->m_source); | ||
| 11462 | |||
| 11463 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12111 times.
|
12111 | global_system_variables.sql_mode = |
| 11464 | expand_sql_mode(global_system_variables.sql_mode, nullptr); | ||
| 11465 |
2/2✓ Branch 0 taken 3 times.
✓ Branch 1 taken 12108 times.
|
12111 | |
| 11466 | if (!my_enable_symlinks) have_symlink = SHOW_OPTION_DISABLED; | ||
| 11467 | |||
| 11468 | /* Set global MyISAM variables from delay_key_write_options */ | ||
| 11469 | fix_delay_key_write(nullptr, nullptr, OPT_GLOBAL); | ||
| 11470 | |||
| 11471 | 12108 | #ifndef _WIN32 | |
| 11472 | 12108 | if (mysqld_chroot) set_root(mysqld_chroot); | |
| 11473 | #endif | ||
| 11474 | 12108 | if (fix_paths()) return 1; | |
| 11475 | 12108 | ||
| 11476 | /* | ||
| 11477 | 12108 | Set some global variables from the global_system_variables | |
| 11478 | 12108 | In most cases the global variables will not be used | |
| 11479 | 12108 | */ | |
| 11480 | my_disable_locking = myisam_single_user = (opt_external_locking == 0); | ||
| 11481 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | my_default_record_cache_size = global_system_variables.read_buff_size; |
| 11482 | |||
| 11483 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | global_system_variables.long_query_time = |
| 11484 | ✗ | (ulonglong)(global_system_variables.long_query_time_double * 1e6); | |
| 11485 | ✗ | ||
| 11486 | init_log_slow_verbosity(); | ||
| 11487 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12108 times.
|
12108 | init_slow_query_log_use_global_control(); |
| 11488 | ✗ | init_log_slow_sp_statements(); | |
| 11489 | ✗ | ||
| 11490 | if (opt_short_log_format) opt_specialflag |= SPECIAL_SHORT_LOG_FORMAT; | ||
| 11491 | |||
| 11492 | if (Connection_handler_manager::init()) { | ||
| 11493 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12102 times.
|
12108 | LogErr(ERROR_LEVEL, ER_CONNECTION_HANDLING_OOM); |
| 11494 | 12108 | return 1; | |
| 11495 | } | ||
| 11496 | 12108 | if (Global_THD_manager::create_instance()) { | |
| 11497 | 12108 | LogErr(ERROR_LEVEL, ER_THREAD_HANDLING_OOM); | |
| 11498 | return 1; | ||
| 11499 | } | ||
| 11500 | |||
| 11501 | /* If --super-read-only was specified, set read_only to 1 */ | ||
| 11502 | read_only = super_read_only ? super_read_only : read_only; | ||
| 11503 | opt_readonly = read_only; | ||
| 11504 | |||
| 11505 | return 0; | ||
| 11506 | } | ||
| 11507 | |||
| 11508 | /* | ||
| 11509 | Create version name for running mysqld version | ||
| 11510 | We automatically add suffixes -debug, -valgrind, -asan, -ubsan | ||
| 11511 | to the version name to make the version more descriptive. | ||
| 11512 | (MYSQL_SERVER_SUFFIX is set by the compilation environment) | ||
| 11513 | */ | ||
| 11514 | |||
| 11515 | /* | ||
| 11516 | 12122 | The following code is quite ugly as there is no portable way to easily set a | |
| 11517 | 12122 | string to the value of a macro | |
| 11518 | */ | ||
| 11519 | #ifdef MYSQL_SERVER_SUFFIX | ||
| 11520 |
1/2✓ Branch 0 taken 12122 times.
✗ Branch 1 not taken.
|
12122 | #define MYSQL_SERVER_SUFFIX_STR STRINGIFY_ARG(MYSQL_SERVER_SUFFIX) |
| 11521 | 12122 | #else | |
| 11522 | #define MYSQL_SERVER_SUFFIX_STR MYSQL_SERVER_SUFFIX_DEF | ||
| 11523 | #endif | ||
| 11524 | |||
| 11525 | static void set_server_version(void) { | ||
| 11526 | char *end [[maybe_unused]] = strxmov(server_version, MYSQL_SERVER_VERSION, | ||
| 11527 | MYSQL_SERVER_SUFFIX_STR, NullS); | ||
| 11528 | #ifndef NDEBUG | ||
| 11529 | if (!strstr(MYSQL_SERVER_SUFFIX_STR, "-debug")) | ||
| 11530 | end = my_stpcpy(end, "-debug"); | ||
| 11531 | #endif | ||
| 11532 | #ifdef HAVE_VALGRIND | ||
| 11533 | if (SERVER_VERSION_LENGTH - (end - server_version) > | ||
| 11534 | static_cast<int>(sizeof("-valgrind"))) | ||
| 11535 | end = my_stpcpy(end, "-valgrind"); | ||
| 11536 | #endif | ||
| 11537 | #ifdef HAVE_ASAN | ||
| 11538 | if (SERVER_VERSION_LENGTH - (end - server_version) > | ||
| 11539 | static_cast<int>(sizeof("-asan"))) | ||
| 11540 | end = my_stpcpy(end, "-asan"); | ||
| 11541 | #endif | ||
| 11542 | #ifdef HAVE_LSAN | ||
| 11543 | if (SERVER_VERSION_LENGTH - (end - server_version) > | ||
| 11544 | static_cast<int>(sizeof("-lsan"))) | ||
| 11545 | end = my_stpcpy(end, "-lsan"); | ||
| 11546 | #endif | ||
| 11547 | #ifdef HAVE_UBSAN | ||
| 11548 | if (SERVER_VERSION_LENGTH - (end - server_version) > | ||
| 11549 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12122 times.
|
12122 | static_cast<int>(sizeof("-ubsan"))) |
| 11550 | 12122 | end = my_stpcpy(end, "-ubsan"); | |
| 11551 | #endif | ||
| 11552 | 12122 | #ifdef HAVE_TSAN | |
| 11553 | if (SERVER_VERSION_LENGTH - (end - server_version) > | ||
| 11554 | 36373 | static_cast<int>(sizeof("-tsan"))) | |
| 11555 |
3/6✓ Branch 0 taken 36373 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36373 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 36373 times.
✗ Branch 5 not taken.
|
36373 | end = my_stpcpy(end, "-tsan"); |
| 11556 | #endif | ||
| 11557 | 36373 | ||
| 11558 |
2/2✓ Branch 0 taken 36373 times.
✓ Branch 1 taken 36373 times.
|
72746 | assert(end < server_version + SERVER_VERSION_LENGTH); |
| 11559 | my_stpcpy(server_version_suffix, | ||
| 11560 | 36373 | server_version + strlen(MYSQL_SERVER_VERSION)); | |
| 11561 | } | ||
| 11562 | |||
| 11563 | 73799 | static const char *get_relative_path(const char *path) { | |
| 11564 | if (test_if_hard_path(path) && is_prefix(path, DEFAULT_MYSQL_HOME) && | ||
| 11565 | strcmp(DEFAULT_MYSQL_HOME, FN_ROOTDIR)) { | ||
| 11566 | path += strlen(DEFAULT_MYSQL_HOME); | ||
| 11567 | while (is_directory_separator(*path)) path++; | ||
| 11568 | } | ||
| 11569 |
2/2✓ Branch 0 taken 214 times.
✓ Branch 1 taken 73585 times.
|
73799 | return path; |
| 11570 | } | ||
| 11571 | 73585 | ||
| 11572 | static bool is_secure_path(const char *path, const char *opt_base) { | ||
| 11573 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 73585 times.
|
73585 | char buff1[FN_REFLEN], buff2[FN_REFLEN]; |
| 11574 | size_t opt_base_len; | ||
| 11575 |
3/4✓ Branch 0 taken 73585 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 73578 times.
|
73585 | /* |
| 11576 | All paths are secure if opt_base is 0 | ||
| 11577 |
3/4✓ Branch 0 taken 73578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25518 times.
✓ Branch 3 taken 48060 times.
|
73578 | */ |
| 11578 | if (!opt_base[0]) return true; | ||
| 11579 | |||
| 11580 | opt_base_len = strlen(opt_base); | ||
| 11581 |
1/2✓ Branch 0 taken 25518 times.
✗ Branch 1 not taken.
|
25518 | |
| 11582 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 25518 times.
|
25518 | if (strlen(path) >= FN_REFLEN) return false; |
| 11583 | 25518 | ||
| 11584 | 25518 | if (!my_strcasecmp(system_charset_info, opt_base, "NULL")) return false; | |
| 11585 |
6/8✓ Branch 0 taken 25518 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25518 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 25500 times.
✓ Branch 6 taken 18 times.
✓ Branch 7 taken 25500 times.
|
25518 | |
| 11586 | if (my_realpath(buff1, path, 0)) { | ||
| 11587 |
1/2✓ Branch 0 taken 73560 times.
✗ Branch 1 not taken.
|
73560 | /* |
| 11588 |
1/2✓ Branch 0 taken 73560 times.
✗ Branch 1 not taken.
|
73560 | The supplied file path might have been a file and not a directory. |
| 11589 |
2/2✓ Branch 0 taken 31 times.
✓ Branch 1 taken 73529 times.
|
73560 | */ |
| 11590 | int length = (int)dirname_length(path); | ||
| 11591 | ✗ | if (length >= FN_REFLEN) return false; | |
| 11592 | memcpy(buff2, path, length); | ||
| 11593 | buff2[length] = '\0'; | ||
| 11594 | ✗ | if (length == 0 || my_realpath(buff1, buff2, 0)) return false; | |
| 11595 | } | ||
| 11596 | 73529 | convert_dirname(buff2, buff1, NullS); | |
| 11597 | if (!lower_case_file_system) { | ||
| 11598 | if (strncmp(opt_base, buff2, opt_base_len)) return false; | ||
| 11599 | } else { | ||
| 11600 | if (files_charset_info->coll->strnncoll( | ||
| 11601 | files_charset_info, (uchar *)buff2, strlen(buff2), | ||
| 11602 | pointer_cast<const uchar *>(opt_base), opt_base_len, true)) | ||
| 11603 | return false; | ||
| 11604 | } | ||
| 11605 | return true; | ||
| 11606 | } | ||
| 11607 | |||
| 11608 | 73694 | /** | |
| 11609 | 73694 | Test a file path to determine if the path is compatible with the secure file | |
| 11610 | path restriction. | ||
| 11611 | |||
| 11612 | @param path null terminated character string | ||
| 11613 | |||
| 11614 | @retval true The path is secure | ||
| 11615 | @retval false The path isn't secure | ||
| 11616 | */ | ||
| 11617 | bool is_secure_file_path(const char *path) { | ||
| 11618 | return is_secure_path(path, opt_secure_file_priv); | ||
| 11619 | } | ||
| 11620 | |||
| 11621 | 105 | /** | |
| 11622 | 105 | Test a file path to determine if the path is compatible with the secure log | |
| 11623 | path restriction. | ||
| 11624 | |||
| 11625 | @param path null terminated character string | ||
| 11626 | |||
| 11627 | @retval true The path is secure | ||
| 11628 | @retval false The path isn't secure | ||
| 11629 | */ | ||
| 11630 | bool is_secure_log_path(const char *path) { | ||
| 11631 | return is_secure_path(path, opt_secure_log_path); | ||
| 11632 | } | ||
| 11633 | |||
| 11634 | /** | ||
| 11635 | check_secure_file_priv_path : Checks path specified through | ||
| 11636 | --secure-file-priv and raises warning in following cases: | ||
| 11637 | 1. If path is empty string or NULL and mysqld is not running | ||
| 11638 | with --initialize (bootstrap mode). | ||
| 11639 | 2. If path can access data directory | ||
| 11640 | 3. If path points to a directory which is accessible by | ||
| 11641 | all OS users (non-Windows build only) | ||
| 11642 | |||
| 11643 | It throws error in following cases: | ||
| 11644 | |||
| 11645 | 1. If path normalization fails | ||
| 11646 | 2. If it can not get stats of the directory | ||
| 11647 | |||
| 11648 | Assumptions : | ||
| 11649 | 24190 | 1. Data directory path has been normalized | |
| 11650 | 2. opt_secure_file_priv has been normalized unless it is set | ||
| 11651 | 24190 | to "NULL". | |
| 11652 | 24190 | ||
| 11653 | 24190 | @returns Status of validation | |
| 11654 | 24190 | @retval true : Validation is successful with/without warnings | |
| 11655 | 24190 | @retval false : Validation failed. Error is raised. | |
| 11656 | 24190 | */ | |
| 11657 | 24190 | ||
| 11658 | static bool check_secure_path(const char *opt_var, const char *variable_name, | ||
| 11659 | int warn_empty_err) { | ||
| 11660 | char datadir_buffer[FN_REFLEN + 1] = {0}; | ||
| 11661 | char plugindir_buffer[FN_REFLEN + 1] = {0}; | ||
| 11662 | char whichdir[20] = {0}; | ||
| 11663 |
2/2✓ Branch 0 taken 12645 times.
✓ Branch 1 taken 11545 times.
|
24190 | size_t opt_plugindir_len = 0; |
| 11664 |
2/2✓ Branch 0 taken 600 times.
✓ Branch 1 taken 12045 times.
|
12645 | size_t opt_datadir_len = 0; |
| 11665 | size_t opt_var_len = 0; | ||
| 11666 | bool warn = false; | ||
| 11667 | bool case_insensitive_fs; | ||
| 11668 | #ifndef _WIN32 | ||
| 11669 |
8/16✓ Branch 0 taken 600 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 600 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 600 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 600 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 600 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 600 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 600 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 600 times.
✗ Branch 15 not taken.
|
600 | MY_STAT dir_stat; |
| 11670 | #endif | ||
| 11671 |
8/16✓ Branch 0 taken 12045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12045 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12045 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 12045 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 12045 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 12045 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 12045 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 12045 times.
✗ Branch 15 not taken.
|
12045 | |
| 11672 | if (!opt_var[0]) { | ||
| 11673 | 12645 | if (opt_initialize) { | |
| 11674 | /* | ||
| 11675 | Do not impose --secure-file-priv restriction | ||
| 11676 | in bootstrap mode | ||
| 11677 | */ | ||
| 11678 | LogErr(INFORMATION_LEVEL, ER_SEC_FILE_PRIV_IGNORED, variable_name); | ||
| 11679 | } else { | ||
| 11680 |
3/4✓ Branch 0 taken 11545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 11497 times.
|
11545 | LogErr(WARNING_LEVEL, ER_SEC_FILE_PRIV_EMPTY, variable_name); |
| 11681 |
8/16✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 48 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 48 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 48 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 48 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 48 times.
✗ Branch 15 not taken.
|
48 | } |
| 11682 | 48 | return true; | |
| 11683 | } | ||
| 11684 | |||
| 11685 | /* | ||
| 11686 | Setting --secure-file-priv to NULL would disable | ||
| 11687 | reading/writing from/to file | ||
| 11688 | 11497 | */ | |
| 11689 | if (!my_strcasecmp(system_charset_info, opt_var, "NULL")) { | ||
| 11690 | LogErr(INFORMATION_LEVEL, warn_empty_err, variable_name); | ||
| 11691 | return true; | ||
| 11692 | } | ||
| 11693 | |||
| 11694 |
1/2✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
|
11497 | /* |
| 11695 | 11497 | Check if --secure-file-priv can access data directory | |
| 11696 | */ | ||
| 11697 |
1/2✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
|
11497 | opt_var_len = strlen(opt_var); |
| 11698 | |||
| 11699 |
1/2✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
|
11497 | /* |
| 11700 |
3/4✗ Branch 0 not taken.
✓ Branch 1 taken 11497 times.
✓ Branch 2 taken 11025 times.
✓ Branch 3 taken 472 times.
|
11497 | Adds dir separator at the end. |
| 11701 | This is required in subsequent comparison | ||
| 11702 | */ | ||
| 11703 | 11025 | convert_dirname(datadir_buffer, mysql_unpacked_real_data_home, NullS); | |
| 11704 | 11025 | opt_datadir_len = strlen(datadir_buffer); | |
| 11705 | |||
| 11706 | case_insensitive_fs = (test_if_case_insensitive(datadir_buffer) == 1); | ||
| 11707 | ✗ | ||
| 11708 | if (!case_insensitive_fs) { | ||
| 11709 | if (!strncmp( | ||
| 11710 | ✗ | datadir_buffer, opt_var, | |
| 11711 | ✗ | opt_datadir_len < opt_var_len ? opt_datadir_len : opt_var_len)) { | |
| 11712 | warn = true; | ||
| 11713 | strcpy(whichdir, "Data directory"); | ||
| 11714 | } | ||
| 11715 | } else { | ||
| 11716 | if (!files_charset_info->coll->strnncoll( | ||
| 11717 | files_charset_info, (uchar *)datadir_buffer, opt_datadir_len, | ||
| 11718 | pointer_cast<const uchar *>(opt_var), opt_var_len, true)) { | ||
| 11719 | warn = true; | ||
| 11720 |
6/8✓ Branch 0 taken 472 times.
✓ Branch 1 taken 11025 times.
✓ Branch 2 taken 472 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 472 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 472 times.
✓ Branch 7 taken 11025 times.
|
11497 | strcpy(whichdir, "Data directory"); |
| 11721 |
1/2✓ Branch 0 taken 472 times.
✗ Branch 1 not taken.
|
472 | } |
| 11722 | 472 | } | |
| 11723 | |||
| 11724 |
1/2✓ Branch 0 taken 472 times.
✗ Branch 1 not taken.
|
472 | /* |
| 11725 |
4/4✓ Branch 0 taken 1 times.
✓ Branch 1 taken 471 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 471 times.
|
472 | Don't bother comparing --secure-file-priv with --plugin-dir |
| 11726 | if we already have a match against --datdir or | ||
| 11727 | --plugin-dir is not pointing to a valid directory. | ||
| 11728 | 1 | */ | |
| 11729 | 1 | if (!warn && !my_realpath(plugindir_buffer, opt_plugin_dir, 0)) { | |
| 11730 | convert_dirname(plugindir_buffer, plugindir_buffer, NullS); | ||
| 11731 | opt_plugindir_len = strlen(plugindir_buffer); | ||
| 11732 | ✗ | ||
| 11733 | if (!case_insensitive_fs) { | ||
| 11734 | if (!strncmp(plugindir_buffer, opt_var, | ||
| 11735 | ✗ | opt_plugindir_len < opt_var_len ? opt_plugindir_len | |
| 11736 | ✗ | : opt_var_len)) { | |
| 11737 | warn = true; | ||
| 11738 | strcpy(whichdir, "Plugin directory"); | ||
| 11739 | } | ||
| 11740 | } else { | ||
| 11741 |
2/2✓ Branch 0 taken 11026 times.
✓ Branch 1 taken 471 times.
|
11497 | if (!files_charset_info->coll->strnncoll( |
| 11742 |
8/16✓ Branch 0 taken 11026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11026 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11026 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11026 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11026 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11026 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11026 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11026 times.
✗ Branch 15 not taken.
|
11026 | files_charset_info, (uchar *)plugindir_buffer, opt_plugindir_len, |
| 11743 | pointer_cast<const uchar *>(opt_var), opt_var_len, true)) { | ||
| 11744 | warn = true; | ||
| 11745 | strcpy(whichdir, "Plugin directory"); | ||
| 11746 | } | ||
| 11747 | } | ||
| 11748 | } | ||
| 11749 |
2/4✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11497 times.
|
11497 | |
| 11750 | ✗ | if (warn) | |
| 11751 | ✗ | LogErr(WARNING_LEVEL, ER_SEC_FILE_PRIV_DIRECTORY_INSECURE, variable_name, | |
| 11752 | whichdir, variable_name); | ||
| 11753 | |||
| 11754 |
1/2✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
|
11497 | #ifndef _WIN32 |
| 11755 |
8/16✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11497 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11497 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 11497 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 11497 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 11497 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 11497 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 11497 times.
✗ Branch 15 not taken.
|
11497 | /* |
| 11756 | Check for --secure-file-priv directory's permission | ||
| 11757 | */ | ||
| 11758 | 11497 | if (!(my_stat(opt_var, &dir_stat, MYF(0)))) { | |
| 11759 | LogErr(ERROR_LEVEL, ER_SEC_FILE_PRIV_CANT_STAT, variable_name); | ||
| 11760 | return false; | ||
| 11761 | } | ||
| 11762 | |||
| 11763 | if (dir_stat.st_mode & S_IRWXO) | ||
| 11764 | LogErr(WARNING_LEVEL, ER_SEC_FILE_PRIV_DIRECTORY_PERMISSIONS, | ||
| 11765 | variable_name); | ||
| 11766 | #endif | ||
| 11767 | return true; | ||
| 11768 | } | ||
| 11769 | |||
| 11770 | /** | ||
| 11771 | check_secure_file_priv_path : Checks path specified through | ||
| 11772 | --secure-file-priv and raises warning in following cases: | ||
| 11773 | 1. If path is empty string or NULL and mysqld is not running | ||
| 11774 | with --initialize (bootstrap mode). | ||
| 11775 | 2. If path can access data directory | ||
| 11776 | 3. If path points to a directory which is accessible by | ||
| 11777 | all OS users (non-Windows build only) | ||
| 11778 | |||
| 11779 | It throws error in following cases: | ||
| 11780 | |||
| 11781 | 1. If path normalization fails | ||
| 11782 | 2. If it can not get stats of the directory | ||
| 11783 | |||
| 11784 | Assumptions : | ||
| 11785 | 12095 | 1. Data directory path has been normalized | |
| 11786 | 12095 | 2. opt_secure_file_priv has been normalized unless it is set | |
| 11787 | 12095 | to "NULL". | |
| 11788 | |||
| 11789 | @returns Status of validation | ||
| 11790 | 12095 | @retval true : Validation is successful with/without warnings | |
| 11791 | 12095 | @retval false : Validation failed. Error is raised. | |
| 11792 | 12095 | */ | |
| 11793 | |||
| 11794 | static bool check_secure_file_priv_path() { | ||
| 11795 | return check_secure_path(opt_secure_file_priv, "secure-file-priv", | ||
| 11796 | ER_SEC_FILE_PRIV_NULL); | ||
| 11797 | } | ||
| 11798 | |||
| 11799 | static bool check_secure_log_path() { | ||
| 11800 | return check_secure_path(opt_secure_log_path, "secure-log-path", | ||
| 11801 | ER_SEC_LOG_PATH_NULL); | ||
| 11802 | } | ||
| 11803 | |||
| 11804 | #ifdef WIN32 | ||
| 11805 | // check_tmpdir_path_lengths returns true if all paths are valid, | ||
| 11806 | // false if any path is too long. | ||
| 11807 | static bool check_tmpdir_path_lengths(const MY_TMPDIR &tmpdir_list) { | ||
| 11808 | const size_t max_tmpdir_len = MAX_PATH - MY_MAX_TEMP_FILENAME_LEN; | ||
| 11809 | bool result = true; | ||
| 11810 | for (uint i = 0; i <= tmpdir_list.max; i++) { | ||
| 11811 | std::string tmpdir_entry(tmpdir_list.list[i]); | ||
| 11812 | const int path_separator_reqd = | ||
| 11813 | is_directory_separator(tmpdir_entry.back()) ? 0 : 1; | ||
| 11814 | if ((tmpdir_entry.length() + path_separator_reqd) > max_tmpdir_len) { | ||
| 11815 | 24191 | LogErr(ERROR_LEVEL, ER_TMPDIR_PATH_TOO_LONG, tmpdir_list.list[i], | |
| 11816 | max_tmpdir_len, MY_MAX_TEMP_FILENAME_LEN); | ||
| 11817 | 24191 | result = false; | |
| 11818 | } | ||
| 11819 | } | ||
| 11820 | return result; | ||
| 11821 | } | ||
| 11822 |
2/2✓ Branch 0 taken 600 times.
✓ Branch 1 taken 23591 times.
|
24191 | #endif |
| 11823 | 24191 | ||
| 11824 | static int fix_secure_path(const char *&opt_path, char *realpath, | ||
| 11825 |
3/4✓ Branch 0 taken 11546 times.
✓ Branch 1 taken 12645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11546 times.
|
24191 | const char *variable_name) { |
| 11826 | ✗ | bool opt_nonempty = false; | |
| 11827 | /* | ||
| 11828 | ✗ | Convert the secure-file-priv/secure-log-path option to system format, | |
| 11829 | allowing a quick strcmp to check if read or write is in an allowed dir | ||
| 11830 | */ | ||
| 11831 | 24191 | if (opt_initialize) opt_path = ""; | |
| 11832 | opt_nonempty = opt_path[0] ? true : false; | ||
| 11833 | |||
| 11834 |
7/8✓ Branch 0 taken 11546 times.
✓ Branch 1 taken 12645 times.
✓ Branch 2 taken 11546 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11498 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 11498 times.
✓ Branch 7 taken 12693 times.
|
24191 | if (opt_nonempty && strlen(opt_path) > FN_REFLEN) { |
| 11835 |
1/2✓ Branch 0 taken 11498 times.
✗ Branch 1 not taken.
|
11498 | LogErr(WARNING_LEVEL, ER_SEC_FILE_PRIV_ARGUMENT_TOO_LONG, variable_name, |
| 11836 |
2/2✓ Branch 0 taken 11497 times.
✓ Branch 1 taken 1 times.
|
11498 | FN_REFLEN - 1); |
| 11837 |
1/2✓ Branch 0 taken 11497 times.
✗ Branch 1 not taken.
|
11497 | return 1; |
| 11838 | } | ||
| 11839 | |||
| 11840 | char buff[FN_REFLEN] = { | ||
| 11841 | 0, | ||
| 11842 | }; | ||
| 11843 | if (opt_nonempty && my_strcasecmp(system_charset_info, opt_path, "NULL")) { | ||
| 11844 | int retval = my_realpath(buff, opt_path, MYF(MY_WME)); | ||
| 11845 | if (!retval) { | ||
| 11846 | convert_dirname(realpath, buff, NullS); | ||
| 11847 | #ifdef WIN32 | ||
| 11848 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11497 times.
|
11498 | MY_DIR *dir = my_dir(realpath, MYF(MY_DONT_SORT + MY_WME)); |
| 11849 |
8/16✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 1 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 1 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
|
1 | if (!dir) { |
| 11850 | retval = 1; | ||
| 11851 | 1 | } else { | |
| 11852 | my_dirend(dir); | ||
| 11853 | 11497 | } | |
| 11854 | #endif | ||
| 11855 | } | ||
| 11856 | 24190 | ||
| 11857 | if (retval) { | ||
| 11858 | LogErr(ERROR_LEVEL, ER_SEC_FILE_PRIV_CANT_ACCESS_DIR, variable_name, | ||
| 11859 | 12111 | opt_path); | |
| 11860 | return 1; | ||
| 11861 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | } |
| 11862 | opt_path = realpath; | ||
| 11863 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | } |
| 11864 | |||
| 11865 | 12111 | return 0; | |
| 11866 |
3/4✓ Branch 0 taken 12059 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 12059 times.
✗ Branch 3 not taken.
|
12111 | } |
| 11867 | 12111 | ||
| 11868 | 12111 | static int fix_paths(void) { | |
| 11869 | char buff[FN_REFLEN]; | ||
| 11870 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | convert_dirname(mysql_home, mysql_home, NullS); |
| 11871 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | /* Resolve symlinks to allow 'mysql_home' to be a relative symlink */ |
| 11872 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | my_realpath(mysql_home, mysql_home, MYF(0)); |
| 11873 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | /* Ensure that mysql_home ends in FN_LIBCHAR */ |
| 11874 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | char *pos = strend(mysql_home); |
| 11875 | if (pos == mysql_home || pos[-1] != FN_LIBCHAR) { | ||
| 11876 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | pos[0] = FN_LIBCHAR; |
| 11877 | pos[1] = 0; | ||
| 11878 |
3/4✓ Branch 0 taken 6069 times.
✓ Branch 1 taken 6042 times.
✓ Branch 2 taken 6069 times.
✗ Branch 3 not taken.
|
12111 | } |
| 11879 | convert_dirname(lc_messages_dir, lc_messages_dir, NullS); | ||
| 11880 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | convert_dirname(mysql_real_data_home, mysql_real_data_home, NullS); |
| 11881 | 12111 | (void)my_load_path(mysql_home, mysql_home, ""); // Resolve current dir | |
| 11882 | (void)my_load_path(mysql_real_data_home, mysql_real_data_home, mysql_home); | ||
| 11883 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | (void)my_load_path(pidfile_name, pidfile_name_ptr, mysql_real_data_home); |
| 11884 | 12111 | ||
| 11885 |
2/2✓ Branch 0 taken 117 times.
✓ Branch 1 taken 11994 times.
|
12111 | convert_dirname( |
| 11886 | opt_plugin_dir, | ||
| 11887 | 117 | opt_plugin_dir_ptr ? opt_plugin_dir_ptr : get_relative_path(PLUGINDIR), | |
| 11888 | NullS); | ||
| 11889 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | (void)my_load_path(opt_plugin_dir, opt_plugin_dir, mysql_home); |
| 11890 |
2/4✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12111 times.
|
12111 | opt_plugin_dir_ptr = opt_plugin_dir; |
| 11891 | ✗ | ||
| 11892 | my_realpath(mysql_unpacked_real_data_home, mysql_real_data_home, MYF(0)); | ||
| 11893 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | mysql_unpacked_real_data_home_len = strlen(mysql_unpacked_real_data_home); |
| 11894 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | if (mysql_unpacked_real_data_home[mysql_unpacked_real_data_home_len - 1] == |
| 11895 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | FN_LIBCHAR) |
| 11896 | --mysql_unpacked_real_data_home_len; | ||
| 11897 | |||
| 11898 |
2/2✓ Branch 0 taken 11676 times.
✓ Branch 1 taken 435 times.
|
12111 | const char *sharedir = get_relative_path(SHAREDIR); |
| 11899 |
1/2✓ Branch 0 taken 11676 times.
✗ Branch 1 not taken.
|
11676 | if (test_if_hard_path(sharedir)) |
| 11900 | strmake(buff, sharedir, sizeof(buff) - 1); /* purecov: tested */ | ||
| 11901 |
1/2✓ Branch 0 taken 435 times.
✗ Branch 1 not taken.
|
435 | else |
| 11902 | strxnmov(buff, sizeof(buff) - 1, mysql_home, sharedir, NullS); | ||
| 11903 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | convert_dirname(buff, buff, NullS); |
| 11904 |
1/2✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
|
12111 | (void)my_load_path(lc_messages_dir, lc_messages_dir, buff); |
| 11905 | 12111 | ||
| 11906 | /* If --character-sets-dir isn't given, use shared library dir */ | ||
| 11907 |
3/4✓ Branch 0 taken 12111 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 12109 times.
|
12111 | if (charsets_dir) |
| 11908 | strmake(mysql_charsets_dir, charsets_dir, sizeof(mysql_charsets_dir) - 1); | ||
| 11909 | else | ||
| 11910 | strxnmov(mysql_charsets_dir, sizeof(mysql_charsets_dir) - 1, buff, | ||
| 11911 |
3/4✓ Branch 0 taken 433 times.
✓ Branch 1 taken 11676 times.
✓ Branch 2 taken 433 times.
✗ Branch 3 not taken.
|
12109 | CHARSET_DIR, NullS); |
| 11912 |
3/4✓ Branch 0 taken 8936 times.
✓ Branch 1 taken 3173 times.
✓ Branch 2 taken 8936 times.
✗ Branch 3 not taken.
|
12109 | (void)my_load_path(mysql_charsets_dir, mysql_charsets_dir, buff); |
| 11913 | convert_dirname(mysql_charsets_dir, mysql_charsets_dir, NullS); | ||
| 11914 |
2/2✓ Branch 0 taken 13 times.
✓ Branch 1 taken 12096 times.
|
12109 | charsets_dir = mysql_charsets_dir; |
| 11915 | |||
| 11916 |
3/4✓ Branch 0 taken 12096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 12095 times.
|
12096 | if (init_tmpdir(&mysql_tmpdir_list, opt_mysql_tmpdir)) return 1; |
| 11917 | #ifdef WIN32 | ||
| 11918 | 1 | if (!check_tmpdir_path_lengths(mysql_tmpdir_list)) return 1; | |
| 11919 |
2/4✓ Branch 0 taken 12095 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12095 times.
|
12095 | #endif |
| 11920 | if (!opt_mysql_tmpdir) opt_mysql_tmpdir = mysql_tmpdir; | ||
| 11921 |
2/4✓ Branch 0 taken 12095 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12095 times.
|
12095 | if (!replica_load_tmpdir) replica_load_tmpdir = mysql_tmpdir; |
| 11922 | |||
| 11923 | ✗ | if (opt_help) return 0; | |
| 11924 |
2/4✓ Branch 0 taken 12095 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12095 times.
|
12095 | |
| 11925 | if (fix_secure_path(opt_secure_file_priv, secure_file_real_path, | ||
| 11926 | 12095 | "secure-file-priv")) | |
| 11927 | return 1; | ||
| 11928 | if (!check_secure_file_priv_path()) return 1; | ||
| 11929 | |||
| 11930 | if (fix_secure_path(opt_secure_log_path, secure_log_real_path, | ||
| 11931 | "secure-log-path")) | ||
| 11932 | return 1; | ||
| 11933 | if (!check_secure_log_path()) return 1; | ||
| 11934 | |||
| 11935 | return 0; | ||
| 11936 | } | ||
| 11937 | |||
| 11938 | /** | ||
| 11939 | Check if file system used for databases is case insensitive. | ||
| 11940 | |||
| 11941 | @param dir_name Directory to test | ||
| 11942 | 23594 | ||
| 11943 | 23594 | @retval | |
| 11944 | -1 Don't know (Test failed) | ||
| 11945 | @retval | ||
| 11946 | 0 File system is case sensitive | ||
| 11947 | 23594 | @retval | |
| 11948 |
1/2✓ Branch 0 taken 23594 times.
✗ Branch 1 not taken.
|
23594 | 1 File system is case insensitive |
| 11949 | */ | ||
| 11950 |
1/2✓ Branch 0 taken 23594 times.
✗ Branch 1 not taken.
|
23594 | |
| 11951 | static int test_if_case_insensitive(const char *dir_name) { | ||
| 11952 |
1/2✓ Branch 0 taken 23594 times.
✗ Branch 1 not taken.
|
23594 | int result = 0; |
| 11953 | File file; | ||
| 11954 |
1/2✓ Branch 0 taken 23594 times.
✗ Branch 1 not taken.
|
23594 | char buff[FN_REFLEN], buff2[FN_REFLEN]; |
| 11955 |
1/2✓ Branch 0 taken 23594 times.
✗ Branch 1 not taken.
|
23594 | MY_STAT stat_info; |
| 11956 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 23578 times.
|
23594 | const char *const tmp_file_name = "mysqld_tmp_file_case_insensitive_test"; |
| 11957 |
8/16✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 16 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 16 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 16 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16 times.
✗ Branch 15 not taken.
|
16 | DBUG_TRACE; |
| 11958 | 16 | ||
| 11959 | fn_format(buff, tmp_file_name, dir_name, ".lower-test", | ||
| 11960 |
1/2✓ Branch 0 taken 23578 times.
✗ Branch 1 not taken.
|
23578 | MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR); |
| 11961 |
2/4✓ Branch 0 taken 23578 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 23578 times.
|
23578 | fn_format(buff2, tmp_file_name, dir_name, ".LOWER-TEST", |
| 11962 | ✗ | MY_UNPACK_FILENAME | MY_REPLACE_EXT | MY_REPLACE_DIR); | |
| 11963 |
1/2✓ Branch 0 taken 23578 times.
✗ Branch 1 not taken.
|
23578 | mysql_file_delete(key_file_casetest, buff2, MYF(0)); |
| 11964 |
3/8✓ Branch 0 taken 23578 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23578 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 23578 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
23578 | if ((file = mysql_file_create(key_file_casetest, buff, 0666, O_RDWR, |
| 11965 | 23578 | MYF(0))) < 0) { | |
| 11966 | 23594 | LogErr(WARNING_LEVEL, ER_CANT_CREATE_TEST_FILE, buff); | |
| 11967 | return -1; | ||
| 11968 | } | ||
| 11969 | mysql_file_close(file, MYF(0)); | ||
| 11970 | if (mysql_file_stat(key_file_casetest, buff2, &stat_info, MYF(0))) | ||
| 11971 | 11443 | result = 1; // Can access file | |
| 11972 | mysql_file_delete(key_file_casetest, buff, MYF(MY_WME)); | ||
| 11973 | 11443 | DBUG_PRINT("exit", ("result: %d", result)); | |
| 11974 | 11443 | return result; | |
| 11975 | } | ||
| 11976 | 11443 | ||
| 11977 | /** | ||
| 11978 | Create file to store pid number. | ||
| 11979 | */ | ||
| 11980 |
7/8✓ Branch 0 taken 114121 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 114121 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 102732 times.
✓ Branch 5 taken 11389 times.
✓ Branch 6 taken 102732 times.
✓ Branch 7 taken 11443 times.
|
114175 | static bool create_pid_file() { |
| 11981 | File file; | ||
| 11982 | bool check_parent_path = true, is_path_accessible = true; | ||
| 11983 | 102732 | char pid_filepath[FN_REFLEN], *pos = nullptr; | |
| 11984 |
3/7✓ Branch 0 taken 102732 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 102678 times.
✗ Branch 6 not taken.
|
102732 | /* Copy pid file name to get pid file path */ |
| 11985 | ✗ | strcpy(pid_filepath, pidfile_name); | |
| 11986 | ✗ | ||
| 11987 | ✗ | /* Iterate through the entire path to check if even one of the sub-dirs | |
| 11988 | ✗ | is world-writable */ | |
| 11989 | ✗ | while (check_parent_path && (pos = strrchr(pid_filepath, FN_LIBCHAR)) && | |
| 11990 | ✗ | (pos != pid_filepath)) /* shouldn't check root */ | |
| 11991 | 54 | { | |
| 11992 |
8/16✓ Branch 0 taken 54 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 54 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 54 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 54 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 54 times.
✗ Branch 15 not taken.
|
54 | *pos = '\0'; /* Trim the inner-most dir */ |
| 11993 | switch (is_file_or_dir_world_writable(pid_filepath)) { | ||
| 11994 | 54 | case -2: | |
| 11995 | 54 | is_path_accessible = false; | |
| 11996 | 102678 | break; | |
| 11997 | 102678 | case -1: | |
| 11998 | LogErr(ERROR_LEVEL, ER_CANT_CHECK_PID_PATH, strerror(errno)); | ||
| 11999 | exit(MYSQLD_ABORT_EXIT); | ||
| 12000 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 11443 times.
|
11443 | case 1: |
| 12001 | ✗ | LogErr(WARNING_LEVEL, ER_PID_FILE_PRIV_DIRECTORY_INSECURE, | |
| 12002 | pid_filepath); | ||
| 12003 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | check_parent_path = false; |
| 12004 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | break; |
| 12005 | case 0: | ||
| 12006 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | continue; /* Keep checking the parent dir */ |
| 12007 | 11443 | } | |
| 12008 |
2/4✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11443 times.
✗ Branch 3 not taken.
|
11443 | } |
| 12009 | if (!is_path_accessible) { | ||
| 12010 |
1/2✓ Branch 0 taken 11443 times.
✗ Branch 1 not taken.
|
11443 | LogErr(WARNING_LEVEL, ER_PID_FILEPATH_LOCATIONS_INACCESSIBLE); |
| 12011 | 11443 | } | |
| 12012 | 11443 | if ((file = mysql_file_create(key_file_pid, pidfile_name, 0664, | |
| 12013 | O_WRONLY | O_TRUNC, MYF(MY_WME))) >= 0) { | ||
| 12014 | ✗ | char buff[MAX_BIGINT_WIDTH + 1], *end; | |
| 12015 | end = longlong10_to_str(getpid(), buff, -10); | ||
| 12016 | ✗ | *end++ = '\n'; | |
| 12017 | ✗ | if (!mysql_file_write(file, (uchar *)buff, (uint)(end - buff), | |
| 12018 | MYF(MY_WME | MY_NABP))) { | ||
| 12019 | mysql_file_close(file, MYF(0)); | ||
| 12020 | pid_file_created = true; | ||
| 12021 | return false; | ||
| 12022 | } | ||
| 12023 | mysql_file_close(file, MYF(0)); | ||
| 12024 | } | ||
| 12025 | LogErr(ERROR_LEVEL, ER_CANT_CREATE_PID_FILE, strerror(errno)); | ||
| 12026 | 10525 | return true; | |
| 12027 | } | ||
| 12028 |
6/6✓ Branch 0 taken 10220 times.
✓ Branch 1 taken 305 times.
✓ Branch 2 taken 9829 times.
✓ Branch 3 taken 391 times.
✓ Branch 4 taken 696 times.
✓ Branch 5 taken 9829 times.
|
20354 | |
| 12029 |
2/4✓ Branch 0 taken 9829 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9829 times.
|
9829 | /** |
| 12030 | 696 | Remove the process' pid file. | |
| 12031 | |||
| 12032 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 9829 times.
|
9829 | @param flags file operation flags |
| 12033 | ✗ | */ | |
| 12034 | ✗ | ||
| 12035 | static void delete_pid_file(myf flags) { | ||
| 12036 | File file; | ||
| 12037 | if (opt_initialize || !pid_file_created || | ||
| 12038 | !(file = mysql_file_open(key_file_pid, pidfile_name, O_RDONLY, flags))) | ||
| 12039 |
1/2✓ Branch 0 taken 9829 times.
✗ Branch 1 not taken.
|
9829 | return; |
| 12040 |
1/2✓ Branch 0 taken 9829 times.
✗ Branch 1 not taken.
|
9829 | |
| 12041 | 9829 | if (file == -1) { | |
| 12042 |
3/6✓ Branch 0 taken 9829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9829 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 9829 times.
✗ Branch 5 not taken.
|
9829 | LogErr(INFORMATION_LEVEL, ER_CANT_REMOVE_PID_FILE, strerror(errno)); |
| 12043 |
1/2✓ Branch 0 taken 9829 times.
✗ Branch 1 not taken.
|
9829 | return; |
| 12044 | 9829 | } | |
| 12045 | |||
| 12046 | 9829 | uchar buff[MAX_BIGINT_WIDTH + 1]; | |
| 12047 | /* Make sure that the pid file was created by the same process. */ | ||
| 12048 | size_t error = mysql_file_read(file, buff, sizeof(buff), flags); | ||
| 12049 | mysql_file_close(file, flags); | ||
| 12050 | buff[sizeof(buff) - 1] = '\0'; | ||
| 12051 | if (error != MY_FILE_ERROR && atol((char *)buff) == (long)getpid()) { | ||
| 12052 | 18 | mysql_file_delete(key_file_pid, pidfile_name, flags); | |
| 12053 | pid_file_created = false; | ||
| 12054 | } | ||
| 12055 | return; | ||
| 12056 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | } |
| 12057 | |||
| 12058 |
1/2✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
|
18 | /** |
| 12059 | Delete mysql.ibd after aborting upgrade. | ||
| 12060 | */ | ||
| 12061 |
2/4✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
|
18 | static void delete_dictionary_tablespace() { |
| 12062 | 18 | char path[FN_REFLEN + 1]; | |
| 12063 | bool not_used; | ||
| 12064 | |||
| 12065 | build_table_filename(path, sizeof(path) - 1, "", "mysql", ".ibd", 0, | ||
| 12066 | ¬_used); | ||
| 12067 | (void)mysql_file_delete(key_file_misc, path, MYF(MY_WME)); | ||
| 12068 | |||
| 12069 | // Drop file which tracks progress of upgrade. | ||
| 12070 | dd::upgrade_57::Upgrade_status().remove(); | ||
| 12071 | } | ||
| 12072 | |||
| 12073 | 183941 | /** | |
| 12074 | 183941 | Returns the current state of the server : booting, operational or shutting | |
| 12075 | down. | ||
| 12076 | |||
| 12077 | @return | ||
| 12078 | SERVER_BOOTING Server is not operational. It is starting. | ||
| 12079 | SERVER_OPERATING Server is fully initialized and operating. | ||
| 12080 | SERVER_SHUTTING_DOWN Server is shutting down. | ||
| 12081 | */ | ||
| 12082 | enum_server_operational_state get_server_state() { | ||
| 12083 | 12467 | return server_operational_state; | |
| 12084 | } | ||
| 12085 |
1/2✓ Branch 0 taken 12467 times.
✗ Branch 1 not taken.
|
12467 | |
| 12086 | 12467 | /** | |
| 12087 | Reset status for all threads. | ||
| 12088 | 12467 | */ | |
| 12089 | 12467 | class Reset_thd_status : public Do_THD_Impl { | |
| 12090 | public: | ||
| 12091 | Reset_thd_status() = default; | ||
| 12092 | void operator()(THD *thd) override { | ||
| 12093 | /* Update the global status if not done so already. */ | ||
| 12094 | if (!thd->status_var_aggregated) { | ||
| 12095 | 3845 | add_to_status(&global_status_var, &thd->status_var); | |
| 12096 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | } |
| 12097 | reset_system_status_vars(&thd->status_var); | ||
| 12098 | } | ||
| 12099 | 3845 | }; | |
| 12100 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | |
| 12101 | /** | ||
| 12102 | 3845 | Reset global and session status variables. | |
| 12103 | */ | ||
| 12104 | void refresh_status() { | ||
| 12105 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | mysql_mutex_lock(&LOCK_status); |
| 12106 | |||
| 12107 | /* For all threads, add status to global status and then reset. */ | ||
| 12108 | Reset_thd_status reset_thd_status; | ||
| 12109 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | Global_THD_manager::get_instance()->do_for_all_thd_copy(&reset_thd_status); |
| 12110 | /* net_buffer_length does not accumulate the historical values */ | ||
| 12111 | global_status_var.net_buffer_length = 0ULL; | ||
| 12112 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE |
| 12113 | 3845 | /* Reset aggregated status counters. */ | |
| 12114 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | reset_pfs_status_stats(); |
| 12115 | #endif | ||
| 12116 | |||
| 12117 | /* Reset some global variables. */ | ||
| 12118 | reset_status_vars(); | ||
| 12119 | |||
| 12120 | /* Reset the counters of all key caches (default and named). */ | ||
| 12121 |
1/2✓ Branch 0 taken 3845 times.
✗ Branch 1 not taken.
|
3845 | process_key_caches(reset_key_cache_counters); |
| 12122 | 3845 | flush_status_time = time((time_t *)nullptr); | |
| 12123 | mysql_mutex_unlock(&LOCK_status); | ||
| 12124 | |||
| 12125 | /* | ||
| 12126 | 591 | Set max_used_connections to the number of currently open | |
| 12127 | 1291 | connections. Do this out of LOCK_status to avoid deadlocks. | |
| 12128 | 1291 | Status reset becomes not atomic, but status data is not exact anyway. | |
| 12129 |
2/2✓ Branch 0 taken 700 times.
✓ Branch 1 taken 591 times.
|
1291 | */ |
| 12130 | Connection_handler_manager::reset_max_used_connections(); | ||
| 12131 | } | ||
| 12132 | |||
| 12133 | class Do_THD_reset_status : public Do_THD_Impl { | ||
| 12134 | public: | ||
| 12135 | Do_THD_reset_status() {} | ||
| 12136 | void operator()(THD *thd) override { | ||
| 12137 | PSI_thread *thread = thd->get_psi(); | ||
| 12138 | if (thread != nullptr) { | ||
| 12139 | 700 | /* | |
| 12140 | During this call, | ||
| 12141 | 1291 | - inspecting the THD associated with the performance schema | |
| 12142 | thread instrumentation, | ||
| 12143 | - inspecting the THD status variable | ||
| 12144 | 591 | is safe, because the call is protected | |
| 12145 | 591 | by Global_THD_manager::do_for_all_thd(), | |
| 12146 |
1/2✓ Branch 0 taken 591 times.
✗ Branch 1 not taken.
|
591 | so the THD will not be destroyed during the iteration. |
| 12147 | 591 | */ | |
| 12148 | PSI_THREAD_CALL(aggregate_thread_status)(thread); | ||
| 12149 | } | ||
| 12150 | } | ||
| 12151 | }; | ||
| 12152 | |||
| 12153 | void reset_status_by_thd() { | ||
| 12154 | Do_THD_reset_status doit; | ||
| 12155 | Global_THD_manager::get_instance()->do_for_all_thd(&doit); | ||
| 12156 | } | ||
| 12157 | |||
| 12158 | /***************************************************************************** | ||
| 12159 | Instantiate variables for missing storage engines | ||
| 12160 | This section should go away soon | ||
| 12161 | *****************************************************************************/ | ||
| 12162 | |||
| 12163 | #ifdef HAVE_PSI_INTERFACE | ||
| 12164 | PSI_mutex_key key_LOCK_tc; | ||
| 12165 | PSI_mutex_key key_hash_filo_lock; | ||
| 12166 | PSI_mutex_key key_LOCK_error_log; | ||
| 12167 | PSI_mutex_key key_LOCK_thd_data; | ||
| 12168 | PSI_mutex_key key_LOCK_thd_sysvar; | ||
| 12169 | PSI_mutex_key key_LOCK_thd_protocol; | ||
| 12170 | PSI_mutex_key key_LOCK_thd_security_ctx; | ||
| 12171 | PSI_mutex_key key_LOG_LOCK_log; | ||
| 12172 | PSI_mutex_key key_source_info_data_lock; | ||
| 12173 | PSI_mutex_key key_source_info_run_lock; | ||
| 12174 | PSI_mutex_key key_source_info_sleep_lock; | ||
| 12175 | PSI_mutex_key key_source_info_thd_lock; | ||
| 12176 | PSI_mutex_key key_source_info_rotate_lock; | ||
| 12177 | PSI_mutex_key key_mutex_replica_reporting_capability_err_lock; | ||
| 12178 | PSI_mutex_key key_relay_log_info_data_lock; | ||
| 12179 | PSI_mutex_key key_relay_log_info_sleep_lock; | ||
| 12180 | PSI_mutex_key key_relay_log_info_thd_lock; | ||
| 12181 | PSI_mutex_key key_relay_log_info_log_space_lock; | ||
| 12182 | PSI_mutex_key key_relay_log_info_run_lock; | ||
| 12183 | PSI_mutex_key key_mutex_slave_parallel_pend_jobs; | ||
| 12184 | PSI_mutex_key key_mutex_slave_parallel_worker_count; | ||
| 12185 | PSI_mutex_key key_mutex_slave_parallel_worker; | ||
| 12186 | PSI_mutex_key key_structure_guard_mutex; | ||
| 12187 | PSI_mutex_key key_TABLE_SHARE_LOCK_ha_data; | ||
| 12188 | PSI_mutex_key key_LOCK_query_plan; | ||
| 12189 | PSI_mutex_key key_LOCK_thd_query; | ||
| 12190 | PSI_mutex_key key_LOCK_cost_const; | ||
| 12191 | PSI_mutex_key key_LOCK_current_cond; | ||
| 12192 | PSI_mutex_key key_LOCK_temporary_tables; | ||
| 12193 | PSI_mutex_key key_LOCK_global_user_client_stats; | ||
| 12194 | PSI_mutex_key key_LOCK_global_table_stats; | ||
| 12195 | PSI_mutex_key key_LOCK_global_index_stats; | ||
| 12196 | PSI_mutex_key key_RELAYLOG_LOCK_commit; | ||
| 12197 | PSI_mutex_key key_RELAYLOG_LOCK_index; | ||
| 12198 | PSI_mutex_key key_RELAYLOG_LOCK_log; | ||
| 12199 | PSI_mutex_key key_RELAYLOG_LOCK_log_end_pos; | ||
| 12200 | PSI_mutex_key key_RELAYLOG_LOCK_sync; | ||
| 12201 | PSI_mutex_key key_RELAYLOG_LOCK_xids; | ||
| 12202 | PSI_mutex_key key_gtid_ensure_index_mutex; | ||
| 12203 | PSI_mutex_key key_object_cache_mutex; // TODO need to initialize | ||
| 12204 | PSI_cond_key key_object_loading_cond; // TODO need to initialize | ||
| 12205 | PSI_mutex_key key_mta_temp_table_LOCK; | ||
| 12206 | PSI_mutex_key key_mta_gaq_LOCK; | ||
| 12207 | PSI_mutex_key key_thd_timer_mutex; | ||
| 12208 | PSI_mutex_key key_commit_order_manager_mutex; | ||
| 12209 | PSI_mutex_key key_mutex_replica_worker_hash; | ||
| 12210 | PSI_mutex_key key_monitor_info_run_lock; | ||
| 12211 | PSI_mutex_key key_LOCK_delegate_connection_mutex; | ||
| 12212 | PSI_mutex_key key_LOCK_group_replication_connection_mutex; | ||
| 12213 | |||
| 12214 | /* clang-format off */ | ||
| 12215 | static PSI_mutex_info all_server_mutexes[]= | ||
| 12216 | { | ||
| 12217 | { &key_LOCK_tc, "TC_LOG_MMAP::LOCK_tc", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12218 | { &key_BINLOG_LOCK_commit, "MYSQL_BIN_LOG::LOCK_commit", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12219 | { &key_BINLOG_LOCK_commit_queue, "MYSQL_BIN_LOG::LOCK_commit_queue", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12220 | { &key_BINLOG_LOCK_done, "MYSQL_BIN_LOG::LOCK_done", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12221 | { &key_BINLOG_LOCK_flush_queue, "MYSQL_BIN_LOG::LOCK_flush_queue", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12222 | { &key_BINLOG_LOCK_index, "MYSQL_BIN_LOG::LOCK_index", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12223 | { &key_BINLOG_LOCK_log, "MYSQL_BIN_LOG::LOCK_log", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12224 | { &key_BINLOG_LOCK_binlog_end_pos, "MYSQL_BIN_LOG::LOCK_binlog_end_pos", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12225 | { &key_BINLOG_LOCK_sync, "MYSQL_BIN_LOG::LOCK_sync", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12226 | { &key_BINLOG_LOCK_sync_queue, "MYSQL_BIN_LOG::LOCK_sync_queue", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12227 | { &key_BINLOG_LOCK_xids, "MYSQL_BIN_LOG::LOCK_xids", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12228 | { &key_RELAYLOG_LOCK_commit, "MYSQL_RELAY_LOG::LOCK_commit", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12229 | { &key_RELAYLOG_LOCK_index, "MYSQL_RELAY_LOG::LOCK_index", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12230 | { &key_RELAYLOG_LOCK_log, "MYSQL_RELAY_LOG::LOCK_log", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12231 | { &key_RELAYLOG_LOCK_log_end_pos, "MYSQL_RELAY_LOG::LOCK_log_end_pos", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12232 | { &key_RELAYLOG_LOCK_sync, "MYSQL_RELAY_LOG::LOCK_sync", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12233 | { &key_RELAYLOG_LOCK_xids, "MYSQL_RELAY_LOG::LOCK_xids", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12234 | { &key_hash_filo_lock, "hash_filo::lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12235 | { &Gtid_set::key_gtid_executed_free_intervals_mutex, "Gtid_set::gtid_executed::free_intervals_mutex", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12236 | { &key_LOCK_bloom_filter, "Bloom_filter", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12237 | { &key_LOCK_crypt, "LOCK_crypt", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12238 | { &key_LOCK_error_log, "LOCK_error_log", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12239 | { &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12240 | #if defined(_WIN32) | ||
| 12241 | { &key_LOCK_handler_count, "LOCK_handler_count", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12242 | { &key_LOCK_global_user_client_stats, | ||
| 12243 | "LOCK_global_user_client_stats", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12244 | { &key_LOCK_global_table_stats, | ||
| 12245 | "LOCK_global_table_stats", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12246 | { &key_LOCK_global_index_stats, | ||
| 12247 | "LOCK_global_index_stats", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12248 | #endif | ||
| 12249 | { &key_LOCK_manager, "LOCK_manager", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12250 | { &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12251 | { &key_LOCK_replica_list, "LOCK_replica_list", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12252 | { &key_LOCK_sql_replica_skip_counter, "LOCK_sql_replica_skip_counter", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12253 | { &key_LOCK_replica_net_timeout, "LOCK_replica_net_timeout", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12254 | { &key_LOCK_replica_trans_dep_tracker, "LOCK_replica_trans_dep_tracker", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12255 | { &key_LOCK_server_started, "LOCK_server_started", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12256 | #if !defined(_WIN32) | ||
| 12257 | { &key_LOCK_socket_listener_active, "LOCK_socket_listener_active", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12258 | { &key_LOCK_start_signal_handler, "LOCK_start_signal_handler", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12259 | #endif | ||
| 12260 | { &key_LOCK_status, "LOCK_status", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12261 | { &key_LOCK_thd_data, "THD::LOCK_thd_data", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12262 | { &key_LOCK_thd_query, "THD::LOCK_thd_query", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12263 | { &key_LOCK_thd_sysvar, "THD::LOCK_thd_sysvar", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12264 | { &key_LOCK_thd_protocol, "THD::LOCK_thd_protocol", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12265 | { &key_LOCK_thd_security_ctx, "THD::LOCK_thd_security_ctx", 0, PSI_VOLATILITY_SESSION, "A lock to control access to a THD's security context"}, | ||
| 12266 | { &key_LOCK_user_conn, "LOCK_user_conn", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12267 | { &key_LOCK_uuid_generator, "LOCK_uuid_generator", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12268 | { &key_LOCK_sql_rand, "LOCK_sql_rand", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12269 | { &key_LOG_LOCK_log, "LOG::LOCK_log", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12270 | { &key_source_info_data_lock, "Source_info::data_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12271 | { &key_source_info_run_lock, "Source_info::run_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12272 | { &key_source_info_sleep_lock, "Source_info::sleep_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12273 | { &key_source_info_thd_lock, "Source_info::info_thd_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12274 | { &key_source_info_rotate_lock, "Source_info::rotate_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12275 | { &key_mutex_replica_reporting_capability_err_lock, "Replica_reporting_capability::err_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12276 | { &key_relay_log_info_data_lock, "Relay_log_info::data_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12277 | { &key_relay_log_info_sleep_lock, "Relay_log_info::sleep_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12278 | { &key_relay_log_info_thd_lock, "Relay_log_info::info_thd_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12279 | { &key_relay_log_info_log_space_lock, "Relay_log_info::log_space_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12280 | { &key_relay_log_info_run_lock, "Relay_log_info::run_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12281 | { &key_mutex_slave_parallel_pend_jobs, "Relay_log_info::pending_jobs_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12282 | { &key_mutex_slave_parallel_worker_count, "Relay_log_info::exit_count_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12283 | { &key_mutex_slave_parallel_worker, "Worker_info::jobs_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12284 | { &key_TABLE_SHARE_LOCK_ha_data, "TABLE_SHARE::LOCK_ha_data", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12285 | { &key_LOCK_error_messages, "LOCK_error_messages", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12286 | { &key_LOCK_log_throttle_qni, "LOCK_log_throttle_qni", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12287 | { &key_gtid_ensure_index_mutex, "Gtid_state", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12288 | { &key_LOCK_query_plan, "THD::LOCK_query_plan", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12289 | { &key_LOCK_cost_const, "Cost_constant_cache::LOCK_cost_const", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12290 | { &key_LOCK_current_cond, "THD::LOCK_current_cond", 0, PSI_VOLATILITY_SESSION, PSI_DOCUMENT_ME}, | ||
| 12291 | { &key_mta_temp_table_LOCK, "key_mta_temp_table_LOCK", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12292 | { &key_LOCK_reset_gtid_table, "LOCK_reset_gtid_table", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12293 | { &key_LOCK_compress_gtid_table, "LOCK_compress_gtid_table", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12294 | { &key_LOCK_collect_instance_log, "LOCK_collect_instance_log", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12295 | { &key_mta_gaq_LOCK, "key_mta_gaq_LOCK", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12296 | { &key_thd_timer_mutex, "thd_timer_mutex", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12297 | { &key_commit_order_manager_mutex, "Commit_order_manager::m_mutex", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12298 | { &key_mutex_replica_worker_hash, "Relay_log_info::replica_worker_hash_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12299 | { &key_LOCK_default_password_lifetime, "LOCK_default_password_lifetime", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12300 | { &key_LOCK_mandatory_roles, "LOCK_mandatory_roles", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12301 | { &key_LOCK_password_history, "LOCK_password_history", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12302 | { &key_LOCK_password_reuse_interval, "LOCK_password_reuse_interval", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12303 | { &key_LOCK_keyring_operations, "LOCK_keyring_operations", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12304 | { &key_LOCK_tls_ctx_options, "LOCK_tls_ctx_options", 0, 0, "A lock to control all of the --ssl-* CTX related command line options for client server connection port"}, | ||
| 12305 | { &key_LOCK_admin_tls_ctx_options, "LOCK_admin_tls_ctx_options", 0, 0, "A lock to control all of the --ssl-* CTX related command line options for administrative connection port"}, | ||
| 12306 | { &key_LOCK_rotate_binlog_master_key, "LOCK_rotate_binlog_master_key", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12307 | { &key_monitor_info_run_lock, "Source_IO_monitor::run_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12308 | { &key_LOCK_delegate_connection_mutex, "LOCK_delegate_connection_mutex", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12309 | { &key_LOCK_group_replication_connection_mutex, "LOCK_group_replication_connection_mutex", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12310 | { &key_LOCK_authentication_policy, "LOCK_authentication_policy", PSI_FLAG_SINGLETON, 0, "A lock to ensure execution of CREATE USER or ALTER USER sql and SET @@global.authentication_policy variable are serialized"}, | ||
| 12311 | { &key_LOCK_global_conn_mem_limit, "LOCK_global_conn_mem_limit", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME} | ||
| 12312 | }; | ||
| 12313 | /* clang-format on */ | ||
| 12314 | |||
| 12315 | PSI_rwlock_key key_rwlock_LOCK_logger; | ||
| 12316 | PSI_rwlock_key key_rwlock_channel_map_lock; | ||
| 12317 | PSI_rwlock_key key_rwlock_channel_lock; | ||
| 12318 | PSI_rwlock_key key_rwlock_receiver_sid_lock; | ||
| 12319 | PSI_rwlock_key key_rwlock_rpl_filter_lock; | ||
| 12320 | PSI_rwlock_key key_rwlock_channel_to_filter_lock; | ||
| 12321 | PSI_rwlock_key key_rwlock_LOCK_consistent_snapshot; | ||
| 12322 | PSI_rwlock_key key_rwlock_Trans_delegate_lock; | ||
| 12323 | PSI_rwlock_key key_rwlock_Server_state_delegate_lock; | ||
| 12324 | PSI_rwlock_key key_rwlock_Binlog_storage_delegate_lock; | ||
| 12325 | PSI_rwlock_key key_rwlock_Binlog_transmit_delegate_lock; | ||
| 12326 | PSI_rwlock_key key_rwlock_Binlog_relay_IO_delegate_lock; | ||
| 12327 | PSI_rwlock_key key_rwlock_resource_group_mgr_map_lock; | ||
| 12328 | |||
| 12329 | /* clang-format off */ | ||
| 12330 | static PSI_rwlock_info all_server_rwlocks[]= | ||
| 12331 | { | ||
| 12332 | { &key_rwlock_Binlog_transmit_delegate_lock, "Binlog_transmit_delegate::lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12333 | { &key_rwlock_Binlog_relay_IO_delegate_lock, "Binlog_relay_IO_delegate::lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12334 | { &key_rwlock_LOCK_logger, "LOGGER::LOCK_logger", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12335 | { &key_rwlock_LOCK_sys_init_connect, "LOCK_sys_init_connect", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12336 | { &key_rwlock_LOCK_sys_init_replica, "LOCK_sys_init_replica", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12337 | { &key_rwlock_LOCK_system_variables_hash, "LOCK_system_variables_hash", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12338 | { &key_rwlock_global_sid_lock, "gtid_commit_rollback", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12339 | { &key_rwlock_gtid_mode_lock, "gtid_mode_lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12340 | { &key_rwlock_channel_map_lock, "channel_map_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12341 | { &key_rwlock_channel_lock, "channel_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12342 | { &key_rwlock_Trans_delegate_lock, "Trans_delegate::lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12343 | { &key_rwlock_Server_state_delegate_lock, "Server_state_delegate::lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12344 | { &key_rwlock_Binlog_storage_delegate_lock, "Binlog_storage_delegate::lock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12345 | { &key_rwlock_receiver_sid_lock, "gtid_retrieved", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12346 | { &key_rwlock_rpl_filter_lock, "rpl_filter_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12347 | { &key_rwlock_channel_to_filter_lock, "channel_to_filter_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12348 | { &key_rwlock_resource_group_mgr_map_lock, "Resource_group_mgr::m_map_rwlock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12349 | #ifdef _WIN32 | ||
| 12350 | { &key_rwlock_LOCK_named_pipe_full_access_group, "LOCK_named_pipe_full_access_group", PSI_FLAG_SINGLETON, 0, | ||
| 12351 | "This lock protects named pipe security attributes, preventing their " | ||
| 12352 | "simultaneous application and modification."}, | ||
| 12353 | #endif // _WIN32 | ||
| 12354 | { &key_rwlock_LOCK_consistent_snapshot, "LOCK_consistent_snapshot", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME} | ||
| 12355 | }; | ||
| 12356 | /* clang-format on */ | ||
| 12357 | |||
| 12358 | PSI_cond_key key_PAGE_cond; | ||
| 12359 | PSI_cond_key key_COND_active; | ||
| 12360 | PSI_cond_key key_COND_pool; | ||
| 12361 | PSI_cond_key key_COND_cache_status_changed; | ||
| 12362 | PSI_cond_key key_item_func_sleep_cond; | ||
| 12363 | PSI_cond_key key_source_info_data_cond; | ||
| 12364 | PSI_cond_key key_source_info_start_cond; | ||
| 12365 | PSI_cond_key key_source_info_stop_cond; | ||
| 12366 | PSI_cond_key key_source_info_sleep_cond; | ||
| 12367 | PSI_cond_key key_source_info_rotate_cond; | ||
| 12368 | PSI_cond_key key_relay_log_info_data_cond; | ||
| 12369 | PSI_cond_key key_relay_log_info_log_space_cond; | ||
| 12370 | PSI_cond_key key_relay_log_info_start_cond; | ||
| 12371 | PSI_cond_key key_relay_log_info_stop_cond; | ||
| 12372 | PSI_cond_key key_relay_log_info_sleep_cond; | ||
| 12373 | PSI_cond_key key_cond_slave_parallel_pend_jobs; | ||
| 12374 | PSI_cond_key key_cond_slave_parallel_worker; | ||
| 12375 | PSI_cond_key key_cond_mta_gaq; | ||
| 12376 | PSI_cond_key key_RELAYLOG_update_cond; | ||
| 12377 | PSI_cond_key key_gtid_ensure_index_cond; | ||
| 12378 | PSI_cond_key key_COND_thr_lock; | ||
| 12379 | PSI_cond_key key_commit_order_manager_cond; | ||
| 12380 | PSI_cond_key key_cond_slave_worker_hash; | ||
| 12381 | PSI_cond_key key_monitor_info_run_cond; | ||
| 12382 | PSI_cond_key key_COND_delegate_connection_cond_var; | ||
| 12383 | PSI_cond_key key_COND_group_replication_connection_cond_var; | ||
| 12384 | |||
| 12385 | /* clang-format off */ | ||
| 12386 | static PSI_cond_info all_server_conds[]= | ||
| 12387 | { | ||
| 12388 | { &key_PAGE_cond, "PAGE::cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12389 | { &key_COND_active, "TC_LOG_MMAP::COND_active", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12390 | { &key_COND_pool, "TC_LOG_MMAP::COND_pool", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12391 | { &key_BINLOG_COND_done, "MYSQL_BIN_LOG::COND_done", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12392 | { &key_BINLOG_COND_flush_queue, "MYSQL_BIN_LOG::COND_flush_queue", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12393 | { &key_BINLOG_update_cond, "MYSQL_BIN_LOG::update_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12394 | { &key_BINLOG_prep_xids_cond, "MYSQL_BIN_LOG::prep_xids_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12395 | { &key_RELAYLOG_update_cond, "MYSQL_RELAY_LOG::update_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12396 | #if defined(_WIN32) | ||
| 12397 | { &key_COND_handler_count, "COND_handler_count", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12398 | #endif | ||
| 12399 | { &key_COND_manager, "COND_manager", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12400 | { &key_COND_server_started, "COND_server_started", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12401 | #if !defined(_WIN32) | ||
| 12402 | { &key_COND_socket_listener_active, "COND_socket_listener_active", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12403 | { &key_COND_start_signal_handler, "COND_start_signal_handler", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12404 | #endif | ||
| 12405 | { &key_COND_thr_lock, "COND_thr_lock", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12406 | { &key_item_func_sleep_cond, "Item_func_sleep::cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12407 | { &key_source_info_data_cond, "Source_info::data_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12408 | { &key_source_info_start_cond, "Source_info::start_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12409 | { &key_source_info_stop_cond, "Source_info::stop_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12410 | { &key_source_info_sleep_cond, "Source_info::sleep_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12411 | { &key_source_info_rotate_cond, "Source_info::rotate_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12412 | { &key_relay_log_info_data_cond, "Relay_log_info::data_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12413 | { &key_relay_log_info_log_space_cond, "Relay_log_info::log_space_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12414 | { &key_relay_log_info_start_cond, "Relay_log_info::start_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12415 | { &key_relay_log_info_stop_cond, "Relay_log_info::stop_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12416 | { &key_relay_log_info_sleep_cond, "Relay_log_info::sleep_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12417 | { &key_cond_slave_parallel_pend_jobs, "Relay_log_info::pending_jobs_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12418 | { &key_cond_slave_parallel_worker, "Worker_info::jobs_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12419 | { &key_cond_mta_gaq, "Relay_log_info::mta_gaq_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12420 | { &key_gtid_ensure_index_cond, "Gtid_state", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12421 | { &key_COND_compress_gtid_table, "COND_compress_gtid_table", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12422 | { &key_commit_order_manager_cond, "Commit_order_manager::m_workers.cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12423 | { &key_cond_slave_worker_hash, "Relay_log_info::replica_worker_hash_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12424 | { &key_monitor_info_run_cond, "Source_IO_monitor::run_cond", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12425 | { &key_COND_delegate_connection_cond_var, "THD::COND_delegate_connection_cond_var", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12426 | { &key_COND_group_replication_connection_cond_var, "THD::COND_group_replication_connection_cond_var", 0, 0, PSI_DOCUMENT_ME} | ||
| 12427 | }; | ||
| 12428 | /* clang-format on */ | ||
| 12429 | |||
| 12430 | PSI_thread_key key_thread_bootstrap; | ||
| 12431 | PSI_thread_key key_thread_handle_manager; | ||
| 12432 | PSI_thread_key key_thread_one_connection; | ||
| 12433 | PSI_thread_key key_thread_compress_gtid_table; | ||
| 12434 | PSI_thread_key key_thread_parser_service; | ||
| 12435 | PSI_thread_key key_thread_handle_con_admin_sockets; | ||
| 12436 | |||
| 12437 | /* clang-format off */ | ||
| 12438 | static PSI_thread_info all_server_threads[]= | ||
| 12439 | { | ||
| 12440 | #if defined (_WIN32) | ||
| 12441 | { &key_thread_handle_con_namedpipes, "con_named_pipes", "con_pipe", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12442 | { &key_thread_handle_con_sharedmem, "con_shared_mem", "con_shm", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12443 | { &key_thread_handle_con_sockets, "con_sockets", "con_sock", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12444 | { &key_thread_handle_shutdown_restart, "shutdown_restart", "down_up", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12445 | #endif /* _WIN32 */ | ||
| 12446 | { &key_thread_bootstrap, "bootstrap", "boot", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12447 | { &key_thread_handle_manager, "manager", "handle_mgr", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12448 | { &key_thread_main, "main", "main", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12449 | { &key_thread_one_connection, "one_connection", "connection", | ||
| 12450 | PSI_FLAG_USER | PSI_FLAG_NO_SEQNUM, 0, PSI_DOCUMENT_ME}, | ||
| 12451 | { &key_thread_signal_hand, "signal_handler", "sig_handler", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12452 | { &key_thread_compress_gtid_table, "compress_gtid_table", "gtid_zip", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12453 | { &key_thread_parser_service, "parser_service", "parser_srv", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12454 | { &key_thread_handle_con_admin_sockets, "admin_interface", "con_admin", PSI_FLAG_USER, 0, PSI_DOCUMENT_ME}, | ||
| 12455 | }; | ||
| 12456 | /* clang-format on */ | ||
| 12457 | |||
| 12458 | PSI_file_key key_file_binlog; | ||
| 12459 | PSI_file_key key_file_binlog_index; | ||
| 12460 | PSI_file_key key_file_dbopt; | ||
| 12461 | PSI_file_key key_file_ERRMSG; | ||
| 12462 | PSI_file_key key_select_to_file; | ||
| 12463 | PSI_file_key key_file_fileparser; | ||
| 12464 | PSI_file_key key_file_frm; | ||
| 12465 | PSI_file_key key_file_load; | ||
| 12466 | PSI_file_key key_file_loadfile; | ||
| 12467 | PSI_file_key key_file_log_event_data; | ||
| 12468 | PSI_file_key key_file_log_event_info; | ||
| 12469 | PSI_file_key key_file_misc; | ||
| 12470 | PSI_file_key key_file_tclog; | ||
| 12471 | PSI_file_key key_file_trg; | ||
| 12472 | PSI_file_key key_file_trn; | ||
| 12473 | PSI_file_key key_file_init; | ||
| 12474 | PSI_file_key key_file_general_log; | ||
| 12475 | PSI_file_key key_file_slow_log; | ||
| 12476 | PSI_file_key key_file_relaylog; | ||
| 12477 | PSI_file_key key_file_relaylog_cache; | ||
| 12478 | PSI_file_key key_file_relaylog_index; | ||
| 12479 | PSI_file_key key_file_relaylog_index_cache; | ||
| 12480 | PSI_file_key key_file_sdi; | ||
| 12481 | PSI_file_key key_file_hash_join; | ||
| 12482 | |||
| 12483 | /* clang-format off */ | ||
| 12484 | static PSI_file_info all_server_files[]= | ||
| 12485 | { | ||
| 12486 | { &key_file_binlog, "binlog", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12487 | { &key_file_binlog_cache, "binlog_cache", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12488 | { &key_file_binlog_index, "binlog_index", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12489 | { &key_file_binlog_index_cache, "binlog_index_cache", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12490 | { &key_file_relaylog, "relaylog", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12491 | { &key_file_relaylog_cache, "relaylog_cache", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12492 | { &key_file_relaylog_index, "relaylog_index", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12493 | { &key_file_relaylog_index_cache, "relaylog_index_cache", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12494 | { &key_file_io_cache, "io_cache", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12495 | { &key_file_casetest, "casetest", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12496 | { &key_file_dbopt, "dbopt", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12497 | { &key_file_ERRMSG, "ERRMSG", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12498 | { &key_select_to_file, "select_to_file", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12499 | { &key_file_fileparser, "file_parser", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12500 | { &key_file_frm, "FRM", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12501 | { &key_file_load, "load", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12502 | { &key_file_loadfile, "LOAD_FILE", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12503 | { &key_file_log_event_data, "log_event_data", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12504 | { &key_file_log_event_info, "log_event_info", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12505 | { &key_file_misc, "misc", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12506 | { &key_file_pid, "pid", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12507 | { &key_file_general_log, "query_log", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12508 | { &key_file_slow_log, "slow_log", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12509 | { &key_file_tclog, "tclog", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12510 | { &key_file_trg, "trigger_name", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12511 | { &key_file_trn, "trigger", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12512 | { &key_file_init, "init", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12513 | { &key_file_sdi, "SDI", 0, 0, PSI_DOCUMENT_ME}, | ||
| 12514 | { &key_file_hash_join, "hash_join", 0, 0, PSI_DOCUMENT_ME} | ||
| 12515 | }; | ||
| 12516 | /* clang-format on */ | ||
| 12517 | #endif /* HAVE_PSI_INTERFACE */ | ||
| 12518 | |||
| 12519 | /* clang-format off */ | ||
| 12520 | PSI_stage_info stage_after_create= { 0, "After create", 0, PSI_DOCUMENT_ME}; | ||
| 12521 | PSI_stage_info stage_alter_inplace_prepare= { 0, "preparing for alter table", 0, PSI_DOCUMENT_ME}; | ||
| 12522 | PSI_stage_info stage_alter_inplace= { 0, "altering table", 0, PSI_DOCUMENT_ME}; | ||
| 12523 | PSI_stage_info stage_alter_inplace_commit= { 0, "committing alter table to storage engine", 0, PSI_DOCUMENT_ME}; | ||
| 12524 | PSI_stage_info stage_changing_source= { 0, "Changing replication source", 0, PSI_DOCUMENT_ME}; | ||
| 12525 | PSI_stage_info stage_checking_source_version= { 0, "Checking source version", 0, PSI_DOCUMENT_ME}; | ||
| 12526 | PSI_stage_info stage_checking_permissions= { 0, "checking permissions", 0, PSI_DOCUMENT_ME}; | ||
| 12527 | PSI_stage_info stage_cleaning_up= { 0, "cleaning up", 0, PSI_DOCUMENT_ME}; | ||
| 12528 | PSI_stage_info stage_closing_tables= { 0, "closing tables", 0, PSI_DOCUMENT_ME}; | ||
| 12529 | PSI_stage_info stage_compressing_gtid_table= { 0, "Compressing gtid_executed table", 0, PSI_DOCUMENT_ME}; | ||
| 12530 | PSI_stage_info stage_connecting_to_source= { 0, "Connecting to source", 0, PSI_DOCUMENT_ME}; | ||
| 12531 | PSI_stage_info stage_converting_heap_to_ondisk= { 0, "converting HEAP to ondisk", 0, PSI_DOCUMENT_ME}; | ||
| 12532 | PSI_stage_info stage_copy_to_tmp_table= { 0, "copy to tmp table", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}; | ||
| 12533 | PSI_stage_info stage_creating_table= { 0, "creating table", 0, PSI_DOCUMENT_ME}; | ||
| 12534 | PSI_stage_info stage_creating_tmp_table= { 0, "Creating tmp table", 0, PSI_DOCUMENT_ME}; | ||
| 12535 | PSI_stage_info stage_deleting_from_main_table= { 0, "deleting from main table", 0, PSI_DOCUMENT_ME}; | ||
| 12536 | PSI_stage_info stage_deleting_from_reference_tables= { 0, "deleting from reference tables", 0, PSI_DOCUMENT_ME}; | ||
| 12537 | PSI_stage_info stage_discard_or_import_tablespace= { 0, "discard_or_import_tablespace", 0, PSI_DOCUMENT_ME}; | ||
| 12538 | PSI_stage_info stage_end= { 0, "end", 0, PSI_DOCUMENT_ME}; | ||
| 12539 | PSI_stage_info stage_executing= { 0, "executing", 0, PSI_DOCUMENT_ME}; | ||
| 12540 | PSI_stage_info stage_execution_of_init_command= { 0, "Execution of init_command", 0, PSI_DOCUMENT_ME}; | ||
| 12541 | PSI_stage_info stage_explaining= { 0, "explaining", 0, PSI_DOCUMENT_ME}; | ||
| 12542 | PSI_stage_info stage_finished_reading_one_binlog_switching_to_next_binlog= { 0, "Finished reading one binlog; switching to next binlog", 0, PSI_DOCUMENT_ME}; | ||
| 12543 | PSI_stage_info stage_flushing_relay_log_and_source_info_repository= { 0, "Flushing relay log and source info repository.", 0, PSI_DOCUMENT_ME}; | ||
| 12544 | PSI_stage_info stage_flushing_relay_log_info_file= { 0, "Flushing relay-log info file.", 0, PSI_DOCUMENT_ME}; | ||
| 12545 | PSI_stage_info stage_freeing_items= { 0, "freeing items", 0, PSI_DOCUMENT_ME}; | ||
| 12546 | PSI_stage_info stage_fulltext_initialization= { 0, "FULLTEXT initialization", 0, PSI_DOCUMENT_ME}; | ||
| 12547 | PSI_stage_info stage_init= { 0, "init", 0, PSI_DOCUMENT_ME}; | ||
| 12548 | PSI_stage_info stage_killing_replica= { 0, "Killing replica", 0, PSI_DOCUMENT_ME}; | ||
| 12549 | PSI_stage_info stage_logging_slow_query= { 0, "logging slow query", 0, PSI_DOCUMENT_ME}; | ||
| 12550 | PSI_stage_info stage_making_temp_file_append_before_load_data= { 0, "Making temporary file (append) before replaying LOAD DATA INFILE", 0, PSI_DOCUMENT_ME}; | ||
| 12551 | PSI_stage_info stage_manage_keys= { 0, "manage keys", 0, PSI_DOCUMENT_ME}; | ||
| 12552 | PSI_stage_info stage_source_has_sent_all_binlog_to_replica= { 0, "Source has sent all binlog to replica; waiting for more updates", 0, PSI_DOCUMENT_ME}; | ||
| 12553 | PSI_stage_info stage_opening_tables= { 0, "Opening tables", 0, PSI_DOCUMENT_ME}; | ||
| 12554 | PSI_stage_info stage_optimizing= { 0, "optimizing", 0, PSI_DOCUMENT_ME}; | ||
| 12555 | PSI_stage_info stage_preparing= { 0, "preparing", 0, PSI_DOCUMENT_ME}; | ||
| 12556 | PSI_stage_info stage_purging_old_relay_logs= { 0, "Purging old relay logs", 0, PSI_DOCUMENT_ME}; | ||
| 12557 | PSI_stage_info stage_query_end= { 0, "query end", 0, PSI_DOCUMENT_ME}; | ||
| 12558 | PSI_stage_info stage_queueing_source_event_to_the_relay_log= { 0, "Queueing source event to the relay log", 0, PSI_DOCUMENT_ME}; | ||
| 12559 | PSI_stage_info stage_reading_event_from_the_relay_log= { 0, "Reading event from the relay log", 0, PSI_DOCUMENT_ME}; | ||
| 12560 | PSI_stage_info stage_registering_replica_on_source= { 0, "Registering replica on source", 0, PSI_DOCUMENT_ME}; | ||
| 12561 | PSI_stage_info stage_removing_tmp_table= { 0, "removing tmp table", 0, PSI_DOCUMENT_ME}; | ||
| 12562 | PSI_stage_info stage_rename= { 0, "rename", 0, PSI_DOCUMENT_ME}; | ||
| 12563 | PSI_stage_info stage_rename_result_table= { 0, "rename result table", 0, PSI_DOCUMENT_ME}; | ||
| 12564 | PSI_stage_info stage_requesting_binlog_dump= { 0, "Requesting binlog dump", 0, PSI_DOCUMENT_ME}; | ||
| 12565 | PSI_stage_info stage_searching_rows_for_update= { 0, "Searching rows for update", 0, PSI_DOCUMENT_ME}; | ||
| 12566 | PSI_stage_info stage_sending_binlog_event_to_replica= { 0, "Sending binlog event to replica", 0, PSI_DOCUMENT_ME}; | ||
| 12567 | PSI_stage_info stage_setup= { 0, "setup", 0, PSI_DOCUMENT_ME}; | ||
| 12568 | PSI_stage_info stage_replica_has_read_all_relay_log= { 0, "Replica has read all relay log; waiting for more updates", 0, PSI_DOCUMENT_ME}; | ||
| 12569 | PSI_stage_info stage_replica_reconnecting_after_failed_binlog_dump_request{ 0, "Reconnecting after a failed binlog dump request", 0, PSI_DOCUMENT_ME}; | ||
| 12570 | PSI_stage_info stage_replica_reconnecting_after_failed_event_read{ 0, "Reconnecting after a failed source event read", 0, PSI_DOCUMENT_ME}; | ||
| 12571 | PSI_stage_info stage_replica_reconnecting_after_failed_registration_on_source{ 0, "Reconnecting after a failed registration on source", 0, PSI_DOCUMENT_ME}; | ||
| 12572 | PSI_stage_info stage_replica_waiting_event_from_coordinator= { 0, "Waiting for an event from Coordinator", 0, PSI_DOCUMENT_ME}; | ||
| 12573 | PSI_stage_info stage_replica_waiting_for_workers_to_process_queue= { 0, "Waiting for replica workers to process their queues", 0, PSI_DOCUMENT_ME}; | ||
| 12574 | PSI_stage_info stage_replica_waiting_to_reconnect_after_failed_binlog_dump_request{ 0, "Waiting to reconnect after a failed binlog dump request", 0, PSI_DOCUMENT_ME}; | ||
| 12575 | PSI_stage_info stage_replica_waiting_to_reconnect_after_failed_event_read{ 0, "Waiting to reconnect after a failed source event read", 0, PSI_DOCUMENT_ME}; | ||
| 12576 | PSI_stage_info stage_replica_waiting_to_reconnect_after_failed_registration_on_source{ 0, "Waiting to reconnect after a failed registration on source", 0, PSI_DOCUMENT_ME}; | ||
| 12577 | PSI_stage_info stage_replica_waiting_worker_queue= { 0, "Waiting for Replica Worker queue", 0, PSI_DOCUMENT_ME}; | ||
| 12578 | PSI_stage_info stage_replica_waiting_worker_to_free_events= { 0, "Waiting for Replica Workers to free pending events", 0, PSI_DOCUMENT_ME}; | ||
| 12579 | PSI_stage_info stage_replica_waiting_worker_to_release_partition= { 0, "Waiting for Replica Worker to release partition", 0, PSI_DOCUMENT_ME}; | ||
| 12580 | PSI_stage_info stage_replica_waiting_workers_to_exit= { 0, "Waiting for workers to exit", 0, PSI_DOCUMENT_ME}; | ||
| 12581 | PSI_stage_info stage_rpl_apply_row_evt_write= { 0, "Applying batch of row changes (write)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}; | ||
| 12582 | PSI_stage_info stage_rpl_apply_row_evt_update= { 0, "Applying batch of row changes (update)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}; | ||
| 12583 | PSI_stage_info stage_rpl_apply_row_evt_delete= { 0, "Applying batch of row changes (delete)", PSI_FLAG_STAGE_PROGRESS, PSI_DOCUMENT_ME}; | ||
| 12584 | PSI_stage_info stage_statistics= { 0, "statistics", 0, PSI_DOCUMENT_ME}; | ||
| 12585 | PSI_stage_info stage_sql_thd_waiting_until_delay= { 0, "Waiting until SOURCE_DELAY seconds after source executed event", 0, PSI_DOCUMENT_ME}; | ||
| 12586 | PSI_stage_info stage_system_lock= { 0, "System lock", 0, PSI_DOCUMENT_ME}; | ||
| 12587 | PSI_stage_info stage_update= { 0, "update", 0, PSI_DOCUMENT_ME}; | ||
| 12588 | PSI_stage_info stage_updating= { 0, "updating", 0, PSI_DOCUMENT_ME}; | ||
| 12589 | PSI_stage_info stage_updating_main_table= { 0, "updating main table", 0, PSI_DOCUMENT_ME}; | ||
| 12590 | PSI_stage_info stage_updating_reference_tables= { 0, "updating reference tables", 0, PSI_DOCUMENT_ME}; | ||
| 12591 | PSI_stage_info stage_user_sleep= { 0, "User sleep", 0, PSI_DOCUMENT_ME}; | ||
| 12592 | PSI_stage_info stage_verifying_table= { 0, "verifying table", 0, PSI_DOCUMENT_ME}; | ||
| 12593 | PSI_stage_info stage_waiting_for_gtid_to_be_committed= { 0, "Waiting for GTID to be committed", 0, PSI_DOCUMENT_ME}; | ||
| 12594 | PSI_stage_info stage_waiting_for_handler_commit= { 0, "waiting for handler commit", 0, PSI_DOCUMENT_ME}; | ||
| 12595 | PSI_stage_info stage_waiting_for_source_to_send_event= { 0, "Waiting for source to send event", 0, PSI_DOCUMENT_ME}; | ||
| 12596 | PSI_stage_info stage_waiting_for_source_update= { 0, "Waiting for source update", 0, PSI_DOCUMENT_ME}; | ||
| 12597 | PSI_stage_info stage_waiting_for_relay_log_space= { 0, "Waiting for the replica SQL thread to free relay log space", 0, PSI_DOCUMENT_ME}; | ||
| 12598 | PSI_stage_info stage_waiting_for_replica_mutex_on_exit= { 0, "Waiting for replica mutex on exit", 0, PSI_DOCUMENT_ME}; | ||
| 12599 | PSI_stage_info stage_waiting_for_replica_thread_to_start= { 0, "Waiting for replica thread to start", 0, PSI_DOCUMENT_ME}; | ||
| 12600 | PSI_stage_info stage_waiting_for_table_flush= { 0, "Waiting for table flush", 0, PSI_DOCUMENT_ME}; | ||
| 12601 | PSI_stage_info stage_waiting_for_the_next_event_in_relay_log= { 0, "Waiting for the next event in relay log", 0, PSI_DOCUMENT_ME}; | ||
| 12602 | PSI_stage_info stage_waiting_for_the_replica_thread_to_advance_position= { 0, "Waiting for the replica SQL thread to advance position", 0, PSI_DOCUMENT_ME}; | ||
| 12603 | PSI_stage_info stage_waiting_to_finalize_termination= { 0, "Waiting to finalize termination", 0, PSI_DOCUMENT_ME}; | ||
| 12604 | PSI_stage_info stage_worker_waiting_for_its_turn_to_commit= { 0, "Waiting for preceding transaction to commit", 0, PSI_DOCUMENT_ME}; | ||
| 12605 | PSI_stage_info stage_worker_waiting_for_commit_parent= { 0, "Waiting for dependent transaction to commit", 0, PSI_DOCUMENT_ME}; | ||
| 12606 | PSI_stage_info stage_suspending= { 0, "Suspending", 0, PSI_DOCUMENT_ME}; | ||
| 12607 | PSI_stage_info stage_starting= { 0, "starting", 0, PSI_DOCUMENT_ME}; | ||
| 12608 | PSI_stage_info stage_waiting_for_no_channel_reference= { 0, "Waiting for no channel reference.", 0, PSI_DOCUMENT_ME}; | ||
| 12609 | PSI_stage_info stage_hook_begin_trans= { 0, "Executing hook on transaction begin.", 0, PSI_DOCUMENT_ME}; | ||
| 12610 | PSI_stage_info stage_binlog_transaction_compress= { 0, "Compressing transaction changes.", 0, PSI_DOCUMENT_ME}; | ||
| 12611 | PSI_stage_info stage_binlog_transaction_decompress= { 0, "Decompressing transaction changes.", 0, PSI_DOCUMENT_ME}; | ||
| 12612 | PSI_stage_info stage_rpl_failover_fetching_source_member_details= { 0, "Fetching source member details from connected source", 0, PSI_DOCUMENT_ME}; | ||
| 12613 | PSI_stage_info stage_rpl_failover_updating_source_member_details= { 0, "Updating fetched source member details on receiver", 0, PSI_DOCUMENT_ME}; | ||
| 12614 | PSI_stage_info stage_rpl_failover_wait_before_next_fetch= { 0, "Wait before trying to fetch next membership changes from source", 0, PSI_DOCUMENT_ME}; | ||
| 12615 | PSI_stage_info stage_communication_delegation= { 0, "Connection delegated to Group Replication", 0, PSI_DOCUMENT_ME}; | ||
| 12616 | PSI_stage_info stage_restoring_secondary_keys= { 0, "restoring secondary keys", 0, PSI_DOCUMENT_ME}; | ||
| 12617 | /* clang-format on */ | ||
| 12618 | |||
| 12619 | extern PSI_stage_info stage_waiting_for_disk_space; | ||
| 12620 | |||
| 12621 | #ifdef HAVE_PSI_INTERFACE | ||
| 12622 | |||
| 12623 | PSI_stage_info *all_server_stages[] = { | ||
| 12624 | &stage_after_create, | ||
| 12625 | &stage_alter_inplace_prepare, | ||
| 12626 | &stage_alter_inplace, | ||
| 12627 | &stage_alter_inplace_commit, | ||
| 12628 | &stage_changing_source, | ||
| 12629 | &stage_checking_source_version, | ||
| 12630 | &stage_checking_permissions, | ||
| 12631 | &stage_cleaning_up, | ||
| 12632 | &stage_closing_tables, | ||
| 12633 | &stage_compressing_gtid_table, | ||
| 12634 | &stage_connecting_to_source, | ||
| 12635 | &stage_converting_heap_to_ondisk, | ||
| 12636 | &stage_copy_to_tmp_table, | ||
| 12637 | &stage_creating_table, | ||
| 12638 | &stage_creating_tmp_table, | ||
| 12639 | &stage_deleting_from_main_table, | ||
| 12640 | &stage_deleting_from_reference_tables, | ||
| 12641 | &stage_discard_or_import_tablespace, | ||
| 12642 | &stage_end, | ||
| 12643 | &stage_executing, | ||
| 12644 | &stage_execution_of_init_command, | ||
| 12645 | &stage_explaining, | ||
| 12646 | &stage_finished_reading_one_binlog_switching_to_next_binlog, | ||
| 12647 | &stage_flushing_relay_log_and_source_info_repository, | ||
| 12648 | &stage_flushing_relay_log_info_file, | ||
| 12649 | &stage_freeing_items, | ||
| 12650 | &stage_fulltext_initialization, | ||
| 12651 | &stage_init, | ||
| 12652 | &stage_killing_replica, | ||
| 12653 | &stage_logging_slow_query, | ||
| 12654 | &stage_making_temp_file_append_before_load_data, | ||
| 12655 | &stage_manage_keys, | ||
| 12656 | &stage_source_has_sent_all_binlog_to_replica, | ||
| 12657 | &stage_opening_tables, | ||
| 12658 | &stage_optimizing, | ||
| 12659 | &stage_preparing, | ||
| 12660 | &stage_purging_old_relay_logs, | ||
| 12661 | &stage_query_end, | ||
| 12662 | &stage_queueing_source_event_to_the_relay_log, | ||
| 12663 | &stage_reading_event_from_the_relay_log, | ||
| 12664 | &stage_registering_replica_on_source, | ||
| 12665 | &stage_removing_tmp_table, | ||
| 12666 | &stage_rename, | ||
| 12667 | &stage_rename_result_table, | ||
| 12668 | &stage_requesting_binlog_dump, | ||
| 12669 | &stage_searching_rows_for_update, | ||
| 12670 | &stage_sending_binlog_event_to_replica, | ||
| 12671 | &stage_setup, | ||
| 12672 | &stage_replica_has_read_all_relay_log, | ||
| 12673 | &stage_replica_reconnecting_after_failed_binlog_dump_request, | ||
| 12674 | &stage_replica_reconnecting_after_failed_event_read, | ||
| 12675 | &stage_replica_reconnecting_after_failed_registration_on_source, | ||
| 12676 | &stage_replica_waiting_event_from_coordinator, | ||
| 12677 | &stage_replica_waiting_for_workers_to_process_queue, | ||
| 12678 | &stage_replica_waiting_worker_queue, | ||
| 12679 | &stage_replica_waiting_to_reconnect_after_failed_binlog_dump_request, | ||
| 12680 | &stage_replica_waiting_to_reconnect_after_failed_event_read, | ||
| 12681 | &stage_replica_waiting_to_reconnect_after_failed_registration_on_source, | ||
| 12682 | &stage_replica_waiting_worker_to_free_events, | ||
| 12683 | &stage_replica_waiting_worker_to_release_partition, | ||
| 12684 | &stage_replica_waiting_workers_to_exit, | ||
| 12685 | &stage_rpl_apply_row_evt_write, | ||
| 12686 | &stage_rpl_apply_row_evt_update, | ||
| 12687 | &stage_rpl_apply_row_evt_delete, | ||
| 12688 | &stage_sql_thd_waiting_until_delay, | ||
| 12689 | &stage_statistics, | ||
| 12690 | &stage_system_lock, | ||
| 12691 | &stage_update, | ||
| 12692 | &stage_updating, | ||
| 12693 | &stage_updating_main_table, | ||
| 12694 | &stage_updating_reference_tables, | ||
| 12695 | &stage_user_sleep, | ||
| 12696 | &stage_verifying_table, | ||
| 12697 | &stage_waiting_for_gtid_to_be_committed, | ||
| 12698 | &stage_waiting_for_handler_commit, | ||
| 12699 | &stage_waiting_for_source_to_send_event, | ||
| 12700 | &stage_waiting_for_source_update, | ||
| 12701 | &stage_waiting_for_relay_log_space, | ||
| 12702 | &stage_waiting_for_replica_mutex_on_exit, | ||
| 12703 | &stage_waiting_for_replica_thread_to_start, | ||
| 12704 | &stage_waiting_for_table_flush, | ||
| 12705 | &stage_waiting_for_the_next_event_in_relay_log, | ||
| 12706 | &stage_waiting_for_the_replica_thread_to_advance_position, | ||
| 12707 | &stage_waiting_to_finalize_termination, | ||
| 12708 | &stage_worker_waiting_for_its_turn_to_commit, | ||
| 12709 | &stage_worker_waiting_for_commit_parent, | ||
| 12710 | &stage_suspending, | ||
| 12711 | &stage_starting, | ||
| 12712 | &stage_waiting_for_no_channel_reference, | ||
| 12713 | &stage_hook_begin_trans, | ||
| 12714 | &stage_waiting_for_disk_space, | ||
| 12715 | &stage_binlog_transaction_compress, | ||
| 12716 | &stage_binlog_transaction_decompress, | ||
| 12717 | &stage_rpl_failover_fetching_source_member_details, | ||
| 12718 | &stage_rpl_failover_updating_source_member_details, | ||
| 12719 | &stage_rpl_failover_wait_before_next_fetch, | ||
| 12720 | &stage_communication_delegation, | ||
| 12721 | &stage_restoring_secondary_keys}; | ||
| 12722 | |||
| 12723 | PSI_socket_key key_socket_tcpip; | ||
| 12724 | PSI_socket_key key_socket_unix; | ||
| 12725 | PSI_socket_key key_socket_client_connection; | ||
| 12726 | |||
| 12727 | /* clang-format off */ | ||
| 12728 | static PSI_socket_info all_server_sockets[]= | ||
| 12729 | { | ||
| 12730 | { &key_socket_tcpip, "server_tcpip_socket", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12731 | { &key_socket_unix, "server_unix_socket", PSI_FLAG_SINGLETON, 0, PSI_DOCUMENT_ME}, | ||
| 12732 | { &key_socket_client_connection, "client_connection", PSI_FLAG_USER, 0, PSI_DOCUMENT_ME} | ||
| 12733 | }; | ||
| 12734 | 12109 | /* clang-format on */ | |
| 12735 | 12109 | ||
| 12736 | /* TODO: find a good header */ | ||
| 12737 | void init_client_psi_keys(void); | ||
| 12738 | 12109 | ||
| 12739 | 12109 | /** | |
| 12740 | Initialise all the performance schema instrumentation points | ||
| 12741 | 12109 | used by the server. | |
| 12742 | 12109 | */ | |
| 12743 | static void init_server_psi_keys(void) { | ||
| 12744 | 12109 | const char *category = "sql"; | |
| 12745 | 12109 | int count; | |
| 12746 | |||
| 12747 | 12109 | count = static_cast<int>(array_elements(all_server_mutexes)); | |
| 12748 | 12109 | mysql_mutex_register(category, all_server_mutexes, count); | |
| 12749 | |||
| 12750 | 12109 | count = static_cast<int>(array_elements(all_server_rwlocks)); | |
| 12751 | 12109 | mysql_rwlock_register(category, all_server_rwlocks, count); | |
| 12752 | |||
| 12753 | 12109 | count = static_cast<int>(array_elements(all_server_conds)); | |
| 12754 | 12109 | mysql_cond_register(category, all_server_conds, count); | |
| 12755 | |||
| 12756 | 12109 | count = static_cast<int>(array_elements(all_server_threads)); | |
| 12757 | 12109 | mysql_thread_register(category, all_server_threads, count); | |
| 12758 | |||
| 12759 | 12109 | count = static_cast<int>(array_elements(all_server_files)); | |
| 12760 | mysql_file_register(category, all_server_files, count); | ||
| 12761 | |||
| 12762 | 12109 | count = static_cast<int>(array_elements(all_server_stages)); | |
| 12763 | mysql_stage_register(category, all_server_stages, count); | ||
| 12764 | |||
| 12765 | 12109 | count = static_cast<int>(array_elements(all_server_sockets)); | |
| 12766 | 12109 | mysql_socket_register(category, all_server_sockets, count); | |
| 12767 | |||
| 12768 | register_server_memory_keys(); | ||
| 12769 | 12109 | ||
| 12770 | 12109 | #ifdef HAVE_PSI_STATEMENT_INTERFACE | |
| 12771 | init_sql_statement_info(); | ||
| 12772 | 12109 | ||
| 12773 | 12109 | /* Register [0 .. SQLCOM_CLONE - 1] as "statement/sql/..." */ | |
| 12774 | count = (int)SQLCOM_CLONE; | ||
| 12775 | 12109 | mysql_statement_register(category, sql_statement_info, count); | |
| 12776 | |||
| 12777 | 12109 | /* Exclude SQLCOM_CLONE as it mutates and is registered as abstract. */ | |
| 12778 | count = (int)SQLCOM_END - (int)SQLCOM_CLONE; | ||
| 12779 | 12109 | mysql_statement_register(category, &sql_statement_info[(int)SQLCOM_CLONE + 1], | |
| 12780 | 12109 | count); | |
| 12781 | category = "abstract"; | ||
| 12782 | mysql_statement_register(category, &sql_statement_info[(int)SQLCOM_CLONE], 1); | ||
| 12783 | |||
| 12784 | init_sp_psi_keys(); | ||
| 12785 | 12109 | ||
| 12786 | 12109 | init_scheduler_psi_keys(); | |
| 12787 | |||
| 12788 | category = "com"; | ||
| 12789 | 12109 | init_com_statement_info(); | |
| 12790 | 12109 | ||
| 12791 | /* | ||
| 12792 | Register [0 .. COM_QUERY - 1] as "statement/com/..." | ||
| 12793 | */ | ||
| 12794 | count = (int)COM_QUERY; | ||
| 12795 | 12109 | mysql_statement_register(category, com_statement_info, count); | |
| 12796 | 12109 | ||
| 12797 | /* Exclude COM_CLONE as it would mutate */ | ||
| 12798 | 12109 | count = (int)COM_CLONE - (int)COM_QUERY - 1; | |
| 12799 | mysql_statement_register(category, &com_statement_info[(int)COM_QUERY + 1], | ||
| 12800 | count); | ||
| 12801 | /* | ||
| 12802 | 12109 | Register [COM_CLONE + 1 .. COM_END] as "statement/com/..." | |
| 12803 | 12109 | */ | |
| 12804 | count = (int)COM_END - (int)COM_CLONE; | ||
| 12805 | mysql_statement_register(category, &com_statement_info[(int)COM_CLONE + 1], | ||
| 12806 | count); | ||
| 12807 | category = "abstract"; | ||
| 12808 | /* | ||
| 12809 | Register [COM_QUERY] as "statement/abstract/com_query" | ||
| 12810 | */ | ||
| 12811 | mysql_statement_register(category, &com_statement_info[(int)COM_QUERY], 1); | ||
| 12812 | mysql_statement_register(category, &com_statement_info[(int)COM_CLONE], 1); | ||
| 12813 | |||
| 12814 | /* | ||
| 12815 | 12109 | When a new packet is received, | |
| 12816 | 12109 | it is instrumented as "statement/abstract/new_packet". | |
| 12817 | 12109 | Based on the packet type found, it later mutates to the | |
| 12818 | 12109 | proper narrow type, for example | |
| 12819 | "statement/abstract/query" or "statement/com/ping". | ||
| 12820 | In cases of "statement/abstract/query", SQL queries are given to | ||
| 12821 | the parser, which mutates the statement type to an even more | ||
| 12822 | 12109 | narrow classification, for example "statement/sql/select". | |
| 12823 | */ | ||
| 12824 | stmt_info_new_packet.m_key = 0; | ||
| 12825 | stmt_info_new_packet.m_name = "new_packet"; | ||
| 12826 | stmt_info_new_packet.m_flags = PSI_FLAG_MUTABLE; | ||
| 12827 | stmt_info_new_packet.m_documentation = | ||
| 12828 | "New packet just received from the network. " | ||
| 12829 | 12109 | "At this point, the real command type is unknown, " | |
| 12830 | 12109 | "the type will be refined after reading the packet header."; | |
| 12831 | 12109 | mysql_statement_register(category, &stmt_info_new_packet, 1); | |
| 12832 | 12109 | ||
| 12833 | /* | ||
| 12834 | Statements processed from the relay log are initially instrumented as | ||
| 12835 | "statement/abstract/relay_log". The parser will mutate the statement type to | ||
| 12836 | 12109 | a more specific classification, for example "statement/sql/insert". | |
| 12837 | */ | ||
| 12838 | stmt_info_rpl.m_key = 0; | ||
| 12839 | stmt_info_rpl.m_name = "relay_log"; | ||
| 12840 | 12109 | stmt_info_rpl.m_flags = PSI_FLAG_MUTABLE; | |
| 12841 | stmt_info_rpl.m_documentation = | ||
| 12842 | 12109 | "New event just read from the relay log. " | |
| 12843 | "At this point, the real statement type is unknown, " | ||
| 12844 | 12109 | "the type will be refined after parsing the event."; | |
| 12845 | 12109 | mysql_statement_register(category, &stmt_info_rpl, 1); | |
| 12846 | #endif | ||
| 12847 | |||
| 12848 | 17307 | /* Common client and server code. */ | |
| 12849 | 17307 | init_client_psi_keys(); | |
| 12850 | 17307 | /* Vio */ | |
| 12851 | 17307 | init_vio_psi_keys(); | |
| 12852 |
1/2✓ Branch 0 taken 17307 times.
✗ Branch 1 not taken.
|
17307 | /* TLS interfaces */ |
| 12853 | init_tls_psi_keys(); | ||
| 12854 | } | ||
| 12855 |
2/4✓ Branch 0 taken 17307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17307 times.
|
17307 | #endif /* HAVE_PSI_INTERFACE */ |
| 12856 | |||
| 12857 | bool do_create_native_table_for_pfs(THD *thd, const Plugin_table *t) { | ||
| 12858 | ✗ | const char *schema_name = t->get_schema_name(); | |
| 12859 | const char *table_name = t->get_name(); | ||
| 12860 | MDL_request table_request; | ||
| 12861 |
1/2✓ Branch 0 taken 17307 times.
✗ Branch 1 not taken.
|
17307 | MDL_REQUEST_INIT(&table_request, MDL_key::TABLE, schema_name, table_name, |
| 12862 | MDL_EXCLUSIVE, MDL_TRANSACTION); | ||
| 12863 |
2/4✓ Branch 0 taken 17307 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17307 times.
|
17307 | |
| 12864 | if (thd->mdl_context.acquire_lock(&table_request, | ||
| 12865 | ✗ | thd->variables.lock_wait_timeout)) { | |
| 12866 | /* Error, failed to get MDL lock. */ | ||
| 12867 | return true; | ||
| 12868 | 17307 | } | |
| 12869 | |||
| 12870 | tdc_remove_table(thd, TDC_RT_REMOVE_ALL, schema_name, table_name, false); | ||
| 12871 | 17308 | ||
| 12872 | if (dd::create_native_table(thd, t)) { | ||
| 12873 |
2/2✓ Branch 0 taken 1 times.
✓ Branch 1 taken 17307 times.
|
17308 | /* Error, failed to create DD table. */ |
| 12874 | return true; | ||
| 12875 | 17307 | } | |
| 12876 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 17307 times.
|
17307 | |
| 12877 | 17307 | return false; | |
| 12878 | } | ||
| 12879 | |||
| 12880 | 11872 | bool create_native_table_for_pfs(const Plugin_table *t) { | |
| 12881 | /* If InnoDB is not initialized yet, return error */ | ||
| 12882 | 11872 | if (!is_builtin_and_core_se_initialized()) return true; | |
| 12883 |
1/2✓ Branch 0 taken 11872 times.
✗ Branch 1 not taken.
|
11872 | |
| 12884 | THD *thd = current_thd; | ||
| 12885 | assert(thd); | ||
| 12886 |
3/4✓ Branch 0 taken 11872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 11871 times.
|
11872 | return do_create_native_table_for_pfs(thd, t); |
| 12887 | } | ||
| 12888 | |||
| 12889 | 1 | static bool do_drop_native_table_for_pfs(THD *thd, const char *schema_name, | |
| 12890 | const char *table_name) { | ||
| 12891 | MDL_request table_request; | ||
| 12892 |
1/2✓ Branch 0 taken 11871 times.
✗ Branch 1 not taken.
|
11871 | MDL_REQUEST_INIT(&table_request, MDL_key::TABLE, schema_name, table_name, |
| 12893 | MDL_EXCLUSIVE, MDL_TRANSACTION); | ||
| 12894 |
2/4✓ Branch 0 taken 11871 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11871 times.
|
11871 | |
| 12895 | if (thd->mdl_context.acquire_lock(&table_request, | ||
| 12896 | ✗ | thd->variables.lock_wait_timeout)) { | |
| 12897 | /* Error, failed to get MDL lock. */ | ||
| 12898 | return true; | ||
| 12899 | 11871 | } | |
| 12900 | |||
| 12901 | tdc_remove_table(thd, TDC_RT_REMOVE_ALL, schema_name, table_name, false); | ||
| 12902 | 27118 | ||
| 12903 | if (dd::drop_native_table(thd, schema_name, table_name)) { | ||
| 12904 | /* Error, failed to destroy DD table. */ | ||
| 12905 | return true; | ||
| 12906 | } | ||
| 12907 | |||
| 12908 |
2/2✓ Branch 0 taken 15160 times.
✓ Branch 1 taken 11958 times.
|
27118 | return false; |
| 12909 | 15160 | } | |
| 12910 | |||
| 12911 | bool drop_native_table_for_pfs(const char *schema_name, | ||
| 12912 | const char *table_name) { | ||
| 12913 | 11958 | /* If server is shutting down, by the time control reaches here, DD would have | |
| 12914 |
2/2✓ Branch 0 taken 86 times.
✓ Branch 1 taken 11872 times.
|
11958 | * already been shut down. Therefore return success and tables won't be |
| 12915 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
|
86 | * deleted and would be available at next server start. |
| 12916 | 86 | */ | |
| 12917 | if (get_server_state() == SERVER_SHUTTING_DOWN) { | ||
| 12918 | 11872 | return false; | |
| 12919 | } | ||
| 12920 | |||
| 12921 | /* During bootstrap error cleanup, we don't have THD. */ | ||
| 12922 | THD *thd = current_thd; | ||
| 12923 | if (thd == nullptr) { | ||
| 12924 | assert(get_server_state() == SERVER_BOOTING); | ||
| 12925 | return false; | ||
| 12926 | } | ||
| 12927 | return do_drop_native_table_for_pfs(thd, schema_name, table_name); | ||
| 12928 | } | ||
| 12929 | |||
| 12930 | #ifdef _WIN32 | ||
| 12931 | // update_named_pipe_full_access_group returns false on success, true on failure | ||
| 12932 | bool update_named_pipe_full_access_group(const char *new_group_name) { | ||
| 12933 | if (named_pipe_acceptor) { | ||
| 12934 | return named_pipe_listener->update_named_pipe_full_access_group( | ||
| 12935 | new_group_name); | ||
| 12936 | } | ||
| 12937 | return true; | ||
| 12938 | } | ||
| 12939 | |||
| 12940 | 538726 | #endif // _WIN32 | |
| 12941 | 538726 | ||
| 12942 | /** | ||
| 12943 | Get status partial_revokes on server | ||
| 12944 | |||
| 12945 | @return a bool indicating partial_revokes status of the server. | ||
| 12946 | @retval true Parital revokes is ON | ||
| 12947 | @retval flase Partial revokes is OFF | ||
| 12948 | */ | ||
| 12949 | bool mysqld_partial_revokes() { | ||
| 12950 | 12271 | return partial_revokes.load(std::memory_order_relaxed); | |
| 12951 | 12271 | } | |
| 12952 | 12271 | ||
| 12953 | /** | ||
| 12954 | Set partial_revokes with a given value | ||
| 12955 | |||
| 12956 | @param value true or false indicating the status of partial revokes | ||
| 12957 | turned ON/OFF on server. | ||
| 12958 | */ | ||
| 12959 | void set_mysqld_partial_revokes(bool value) { | ||
| 12960 | partial_revokes.store(value, std::memory_order_relaxed); | ||
| 12961 | } | ||
| 12962 | |||
| 12963 | /** | ||
| 12964 | 15692 | If there exists at least one restrictions on any user, | |
| 12965 |
2/2✓ Branch 0 taken 62 times.
✓ Branch 1 taken 15630 times.
|
15692 | then update global variables which track the partial_revokes. |
| 12966 | 62 | ||
| 12967 |
1/2✓ Branch 0 taken 62 times.
✗ Branch 1 not taken.
|
62 | @param thd THD handle |
| 12968 | 62 | ||
| 12969 | 62 | @return a bool indicating partial_revokes status of the server. | |
| 12970 | 62 | @retval true Parital revokes exists; updated the global variables. | |
| 12971 | 15630 | @retval false Partial revokes does not exist. | |
| 12972 | */ | ||
| 12973 | bool check_and_update_partial_revokes_sysvar(THD *thd) { | ||
| 12974 | if (is_partial_revoke_exists(thd)) { | ||
| 12975 | MUTEX_LOCK(lock, &LOCK_partial_revokes); | ||
| 12976 | set_mysqld_partial_revokes(true); | ||
| 12977 | opt_partial_revokes = true; | ||
| 12978 | return true; | ||
| 12979 | } | ||
| 12980 | return false; | ||
| 12981 | } | ||
| 12982 |